Commit dc769b3a authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Queen can create a standalone worker

parent e76e0cae
......@@ -153,11 +153,13 @@ sub create_new_worker {
'resource_class' => $resource_class,
'beekeeper_id' => $beekeeper_id,
);
$self->store( $worker );
my $worker_id = $worker->dbID;
$worker = $self->fetch_by_dbID( $worker_id ) # refresh the object to get the fields initialized at SQL level (timestamps in this case)
or die "Could not fetch worker with dbID=$worker_id";
if (ref($self)) {
$self->store( $worker );
my $worker_id = $worker->dbID;
$worker = $self->fetch_by_dbID( $worker_id ) # refresh the object to get the fields initialized at SQL level (timestamps in this case)
or die "Could not fetch worker with dbID=$worker_id";
}
$worker->set_log_directory_name($hive_log_dir, $worker_log_dir);
......@@ -470,6 +472,9 @@ sub check_for_dead_workers { # scans the whole Valley for lost Workers (but i
sub find_previous_worker_incarnations {
my ($self, $meadow_type, $meadow_name, $process_id) = @_;
# This happens in standalone mode, when there is no database
return [] unless ref($self);
return $self->fetch_all( "status!='DEAD' AND meadow_type='$meadow_type' AND meadow_name='$meadow_name' AND process_id='$process_id'" );
}
......
......@@ -80,7 +80,7 @@ use Bio::EnsEMBL::Hive::AnalysisStats;
use Bio::EnsEMBL::Hive::Limiter;
use Bio::EnsEMBL::Hive::Utils::RedirectStack;
use Bio::EnsEMBL::Hive::Utils::Stopwatch;
use Bio::EnsEMBL::Hive::Utils ('stringify', 'throw');
use Bio::EnsEMBL::Hive::Utils ('dir_revhash', 'stringify', 'throw');
use base ( 'Bio::EnsEMBL::Hive::Storable' );
......@@ -869,8 +869,8 @@ sub set_log_directory_name {
return unless ($hive_log_dir or $worker_log_dir);
my $dir_revhash = dir_revhash($self->dbID);
$worker_log_dir ||= $hive_log_dir .'/'. ($dir_revhash ? "$dir_revhash/" : '') .'worker_id_'.$self->dbID;
my $dir_revhash = dir_revhash($self->dbID // ''); # Database-less workers are not hashed
$worker_log_dir ||= $hive_log_dir .'/'. ($dir_revhash ? "$dir_revhash/" : '') . ($self->adaptor ? 'worker_id_' . $self->dbID : 'standalone/worker_pid_' . $self->process_id);
eval {
make_path( $worker_log_dir );
......@@ -878,7 +878,7 @@ sub set_log_directory_name {
} or die "Could not create '$worker_log_dir' directory : $@";
$self->log_dir( $worker_log_dir );
$self->adaptor->update_log_dir( $self ); # autoloaded
$self->adaptor->update_log_dir( $self ) if $self->adaptor; # autoloaded
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment