From cb25216f4076bc38d392df5836c7d79ba9165159 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 24 Mar 2013 20:22:11 +0000 Subject: [PATCH] make scheduler start automatic based on housekeeping setting existing --- Netdisco/bin/netdisco-daemon-fg | 16 +++++++--------- .../lib/App/Netdisco/Daemon/Worker/Scheduler.pm | 8 +++++--- Netdisco/share/config.yml | 1 - 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Netdisco/bin/netdisco-daemon-fg b/Netdisco/bin/netdisco-daemon-fg index 1bc62e3e..2fc5f787 100755 --- a/Netdisco/bin/netdisco-daemon-fg +++ b/Netdisco/bin/netdisco-daemon-fg @@ -46,8 +46,12 @@ sub build_tasks_list { user_begin => worker_factory('Manager'), }]; - set(daemon_schedulers => 1) - if !defined setting('daemon_schedulers'); + $has_scheduler = (setting('housekeeping') ? 1 : 0); + push @$tasks, { + max_workers => 1, + user_begin => worker_factory('Scheduler'), + } if $has_scheduler; + set(daemon_pollers => 2) if !defined setting('daemon_pollers'); set(daemon_interactives => 2) @@ -55,11 +59,6 @@ sub build_tasks_list { # XXX MCE does not like max_workers => 0 - push @$tasks, { - max_workers => setting('daemon_schedulers'), - user_begin => worker_factory('Scheduler'), - } if setting('daemon_schedulers'); - push @$tasks, { max_workers => setting('daemon_pollers'), user_begin => worker_factory('Poller'), @@ -71,8 +70,7 @@ sub build_tasks_list { } if setting('daemon_interactives'); info sprintf "MCE will load %s tasks: 1 Manager, %s Scheduler, %s Poller, %s Interactive", - (1+ scalar @$tasks), - (setting('daemon_schedulers') || 0), + (1+ scalar @$tasks), $has_scheduler, (setting('daemon_pollers') || 0), (setting('daemon_interactives') || 0); return $tasks; diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Scheduler.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Scheduler.pm index ce8fc506..5d5f89ea 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Scheduler.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Scheduler.pm @@ -26,9 +26,9 @@ sub worker_begin { debug "entering Scheduler ($wid) worker_begin()"; foreach my $a (keys %$jobactions) { - next unless setting('job_schedule') - and exists setting('job_schedule')->{$a}; - my $config = setting('job_schedule')->{$a}; + next unless setting('housekeeping') + and exists setting('housekeeping')->{$a}; + my $config = setting('housekeeping')->{$a}; # accept either single crontab format, or individual time fields my $cron = Algorithm::Cron->new(@{ @@ -62,6 +62,8 @@ sub worker_body { if ($sched->{when}->next_time($win_start) < $win_end) { # queue it! + # due to a table constraint, this will fail if a similar job is + # already queued. try { debug "scheduler ($wid): queueing $a job"; schema('netdisco')->resultset('Admin')->create({ diff --git a/Netdisco/share/config.yml b/Netdisco/share/config.yml index f750e1b0..657978b4 100644 --- a/Netdisco/share/config.yml +++ b/Netdisco/share/config.yml @@ -72,7 +72,6 @@ daemon_sleep_time: 5 # how many daemon processes # NB one worker will always be a Queue Manager -daemon_schedulers: 1 daemon_interactives: 2 daemon_pollers: 0