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,
"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);
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;