From: Thomas Berezansky Date: Wed, 16 May 2012 18:46:36 +0000 (-0400) Subject: Reporter: Allow "graceful" shutdowns X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Ftsbere%2Fkryptonite;p=working%2FEvergreen.git Reporter: Allow "graceful" shutdowns Allow touching of a "kill" file to cause the reporter to stop itself. Signed-off-by: Thomas Berezansky --- diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl index 29b067dad4..9898823093 100755 --- a/Open-ILS/src/reporter/clark-kent.pl +++ b/Open-ILS/src/reporter/clark-kent.pl @@ -29,7 +29,7 @@ use Email::Send; use open ':utf8'; -my ($count, $config, $sleep_interval, $lockfile, $daemon) = (1, 'SYSCONFDIR/opensrf_core.xml', 10, '/tmp/reporter-LOCK'); +my ($count, $config, $sleep_interval, $lockfile, $killfile, $daemon) = (1, 'SYSCONFDIR/opensrf_core.xml', 10, '/tmp/reporter-LOCK', '/tmp/reporter-KILL'); GetOptions( "daemon" => \$daemon, @@ -37,12 +37,17 @@ GetOptions( "concurrency=i" => \$count, "bootstrap|boostrap=s" => \$config, "lockfile=s" => \$lockfile, + "killfile=s" => \$killfile ); if (-e $lockfile) { die "I seem to be running already. If not, remove $lockfile and try again\n"; } +if (-e $killfile) { + die "I am being told to stop running before starting. Please remove $killfile and try again\n"; +} + OpenSRF::System->bootstrap_client( config_file => $config ); my (%data_db, %state_db); @@ -120,6 +125,17 @@ SELECT count(*) WHERE start_time IS NOT NULL AND complete_time IS NULL; SQL +if (-e $killfile) { + if ($running == 0) { + print "Applying Kryptonite.\n"; + unlink($lockfile); + unlink($killfile); + exit 0; + } + # This should stop us from running any more. + $count = 0; +} + if ($count <= $running) { if ($daemon) { $dbh->disconnect;