rename daemon to backend in code

This commit is contained in:
Oliver Gorwits
2017-05-06 16:26:43 +01:00
parent ffe8fc180f
commit 86a605ba68
11 changed files with 69 additions and 66 deletions

View File

@@ -1,9 +1,9 @@
package App::Netdisco::Daemon::Worker::Common;
package App::Netdisco::Backend::Worker::Common;
use Dancer qw/:moose :syntax :script/;
use Try::Tiny;
use App::Netdisco::Util::Daemon;
use App::Netdisco::Util::Backend;
use Role::Tiny;
use namespace::clean;
@@ -18,7 +18,7 @@ sub worker_body {
my $wid = $self->wid;
while (1) {
prctl sprintf 'netdisco-daemon: worker #%s poller: idle', $wid;
prctl sprintf 'netdisco-backend: worker #%s poller: idle', $wid;
my $job = $self->{queue}->dequeue(1);
next unless defined $job;
@@ -26,7 +26,7 @@ sub worker_body {
try {
$job->started(scalar localtime);
prctl sprintf 'netdisco-daemon: worker #%s poller: working on #%s: %s',
prctl sprintf 'netdisco-backend: worker #%s poller: working on #%s: %s',
$wid, $job->job, $job->summary;
info sprintf "pol (%s): starting %s job(%s) at %s",
$wid, $action, $job->job, $job->started;
@@ -50,7 +50,7 @@ sub close_job {
my ($self, $job) = @_;
my $now = scalar localtime;
prctl sprintf 'netdisco-daemon: worker #%s poller: wrapping up %s #%s: %s',
prctl sprintf 'netdisco-backend: worker #%s poller: wrapping up %s #%s: %s',
$self->wid, $job->action, $job->job, $job->status;
info sprintf "pol (%s): wrapping up %s job(%s) - status %s at %s",
$self->wid, $job->action, $job->job, $job->status, $now;

View File

@@ -1,9 +1,9 @@
package App::Netdisco::Daemon::Worker::Manager;
package App::Netdisco::Backend::Worker::Manager;
use Dancer qw/:moose :syntax :script/;
use List::Util 'sum';
use App::Netdisco::Util::Daemon;
use App::Netdisco::Util::Backend;
use Role::Tiny;
use namespace::clean;
@@ -35,12 +35,12 @@ sub worker_body {
my $wid = $self->wid;
if (setting('workers')->{'no_manager'}) {
prctl sprintf 'netdisco-daemon: worker #%s manager: inactive', $wid;
prctl sprintf 'netdisco-backend: worker #%s manager: inactive', $wid;
return debug "mgr ($wid): no need for manager... quitting"
}
while (1) {
prctl sprintf 'netdisco-daemon: worker #%s manager: gathering', $wid;
prctl sprintf 'netdisco-backend: worker #%s manager: gathering', $wid;
my $num_slots = 0;
$num_slots = parse_max_workers( setting('workers')->{tasks} )
@@ -78,7 +78,7 @@ sub worker_body {
}
debug "mgr ($wid): sleeping now...";
prctl sprintf 'netdisco-daemon: worker #%s manager: idle', $wid;
prctl sprintf 'netdisco-backend: worker #%s manager: idle', $wid;
sleep( setting('workers')->{sleep_time} || 1 );
}
}

View File

@@ -1,9 +1,9 @@
package App::Netdisco::Daemon::Worker::Scheduler;
package App::Netdisco::Backend::Worker::Scheduler;
use Dancer qw/:moose :syntax :script/;
use Algorithm::Cron;
use App::Netdisco::Util::Daemon;
use App::Netdisco::Util::Backend;
use Role::Tiny;
use namespace::clean;
@@ -39,7 +39,7 @@ sub worker_body {
my $wid = $self->wid;
unless (setting('schedule')) {
prctl sprintf 'netdisco-daemon: worker #%s scheduler: inactive', $wid;
prctl sprintf 'netdisco-backend: worker #%s scheduler: inactive', $wid;
return debug "sch ($wid): no need for scheduler... quitting"
}
@@ -47,11 +47,11 @@ sub worker_body {
# sleep until some point in the next minute
my $naptime = 60 - (time % 60) + int(rand(45));
prctl sprintf 'netdisco-daemon: worker #%s scheduler: idle', $wid;
prctl sprintf 'netdisco-backend: worker #%s scheduler: idle', $wid;
debug "sched ($wid): sleeping for $naptime seconds";
sleep $naptime;
prctl sprintf 'netdisco-daemon: worker #%s scheduler: queueing', $wid;
prctl sprintf 'netdisco-backend: worker #%s scheduler: queueing', $wid;
# NB next_time() returns the next *after* win_start
my $win_start = time - (time % 60) - 1;