my ($pipeline, $specialization_options, $life_options, $execution_options) = @_;
$worker_stopwatch->_unit(1); # lifespan_sec is in seconds
$worker_stopwatch->restart();
my $hive_dba = $pipeline->hive_dba;
die "Hive's DBAdaptor is not a defined Bio::EnsEMBL::Hive::DBSQL::DBAdaptor\n" unless $hive_dba and $hive_dba->isa('Bio::EnsEMBL::Hive::DBSQL::DBAdaptor');
$specialization_options ||= {};
$life_options ||= {};
$execution_options ||= {};
my $queen = $hive_dba->get_Queen();
die "No Queen, God Bless Her\n" unless $queen and $queen->isa('Bio::EnsEMBL::Hive::Queen');
# Create the worker
my $worker = $queen->create_new_worker(
-preregistered => $specialization_options->{'preregistered'},
-config_files => $execution_options->{'config_files'},
# Resource class:
-resource_class_id => $specialization_options->{'resource_class_id'},
-resource_class_name => $specialization_options->{'resource_class_name'},
-beekeeper_id => $specialization_options->{'beekeeper_id'},
# Worker control parameters:
-job_limit => $life_options->{'job_limit'},
-life_span => $life_options->{'life_span'},
-no_cleanup => $execution_options->{'no_cleanup'},
-no_write => $execution_options->{'no_write'},
-worker_base_temp_dir => $execution_options->{'worker_base_temp_dir'},
-worker_log_dir => $execution_options->{'worker_log_dir'},
-hive_log_dir => $execution_options->{'hive_log_dir'},
-retry_throwing_jobs => $life_options->{'retry_throwing_jobs'},
-can_respecialize => $specialization_options->{'can_respecialize'},
-worker_delay_startup_seconds => $life_options->{'worker_delay_startup_seconds'},
-worker_crash_on_startup_prob => $life_options->{'worker_crash_on_startup_prob'},
# Other parameters:
-
debug => $execution_options->{
'debug'},
);
die "No worker !\n" unless $worker and $worker->isa('Bio::EnsEMBL::Hive::Worker');
# Run the worker
eval {
$worker->run( {
-analyses_pattern => $specialization_options->{'analyses_pattern'},
-job_id => $specialization_options->{'job_id'},
-force => $specialization_options->{'force'},
} );
$hive_dba->dbc->disconnect_if_idle;
1;