diff --git a/Netdisco/bin/netdisco-daemon b/Netdisco/bin/netdisco-daemon index ee7999f5..6e953c78 100755 --- a/Netdisco/bin/netdisco-daemon +++ b/Netdisco/bin/netdisco-daemon @@ -69,6 +69,7 @@ Daemon::Control->new({ sub restarter { my ($daemon, @program_args) = @_; + $0 = 'netdisco-daemon'; my $child = fork_and_start($daemon, @program_args); exit(1) unless $child; diff --git a/Netdisco/bin/netdisco-daemon-fg b/Netdisco/bin/netdisco-daemon-fg index 0d1073d6..86dea474 100755 --- a/Netdisco/bin/netdisco-daemon-fg +++ b/Netdisco/bin/netdisco-daemon-fg @@ -29,7 +29,6 @@ use NetAddr::IP::Lite ':lower'; use List::Util 'sum'; use Role::Tiny::With; use MCE::Signal '-setpgrp'; -setpgrp(0,0); # only portable variety of setpgrp use MCE; # set temporary MCE files' location in home directory @@ -37,6 +36,9 @@ my $home = ($ENV{NETDISCO_HOME} || $ENV{HOME}); my $tmp_dir = ($ENV{NETDISCO_TEMP} || dir($home, 'tmp')); mkdir $tmp_dir if ! -d $tmp_dir; +setpgrp(0,0); # only portable variety of setpgrp +$0 = 'netdisco-daemon: master'; + my $mce = MCE->new( spawn_delay => 0.15, job_delay => 1.15, @@ -92,6 +94,7 @@ sub worker_factory { return sub { my $self = shift; my $wid = $self->wid; + $0 = sprintf 'netdisco-daemon: worker #%s %s: init', $wid, lc($role); info "applying role $role to worker $wid"; # $self->sendto('stderr', ">>> worker $wid starting with role $role\n"); diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm index 2bf17bad..8c5b0799 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Manager.pm @@ -11,11 +11,12 @@ use App::Netdisco::JobQueue qw/jq_locked jq_getsome jq_lock/; sub worker_begin { my $self = shift; my $wid = $self->wid; - debug "entering Manager ($wid) worker_begin()"; - if (setting('workers')->{'no_manager'}) { - return debug "mgr ($wid): no need for manager... skip begin"; - } + return debug "mgr ($wid): no need for manager... skip begin" + if setting('workers')->{'no_manager'}; + + $0 = sprintf 'netdisco-daemon: worker #%s manager: begin', $wid; + debug "entering Manager ($wid) worker_begin()"; # requeue jobs locally debug "mgr ($wid): searching for jobs booked to this processing node"; @@ -34,6 +35,7 @@ sub worker_body { return debug "mgr ($wid): no need for manager... quitting" if setting('workers')->{'no_manager'}; + $0 = sprintf 'netdisco-daemon: worker #%s manager: body', $wid; my $num_slots = sum( 0, map { setting('workers')->{$_} } values %{setting('job_type_keys')} ); @@ -47,6 +49,8 @@ sub worker_body { # check for available local capacity my $job_type = setting('job_types')->{$job->action}; next unless $job_type and $self->do('capacity_for', $job_type); + + $0 = sprintf 'netdisco-daemon: worker #%s manager: booking %s', $wid, $job->id; debug sprintf "mgr (%s): processing node has capacity for job %s (%s)", $wid, $job->id, $job->action; @@ -60,6 +64,7 @@ sub worker_body { } debug "mgr ($wid): sleeping now..."; + $0 = sprintf 'netdisco-daemon: worker #%s manager: idle', $wid; sleep( setting('workers')->{sleep_time} || 2 ); } }