Unlink the lock file as soon as possible if 1) we have not already looked at it and...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 11 Nov 2009 02:04:45 +0000 (02:04 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 11 Nov 2009 02:04:45 +0000 (02:04 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14863 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/support-scripts/action_trigger_runner.pl

index 393fa65..1e502bb 100755 (executable)
@@ -141,7 +141,16 @@ sub run_pending {
     return unless $opt_run_pending;
     my $ses = OpenSRF::AppSession->create('open-ils.trigger');
     my $req = $ses->request('open-ils.trigger.event.run_all_pending' => $opt_granularity);
+
+    my $check_lockfile = 1;
     while(my $resp = $req->recv(timeout => 7200)) {
+        if ($check_lockfile && -e $opt_lockfile) {
+            open LF, $opt_lockfile;
+            my $contents = <LF>;
+            close LF;
+            unlink $opt_lockfile if ($contents == $$);
+            $check_lockfile = 0;
+        }
         if($opt_debug_stdout) {
             print OpenSRF::Utils::JSON->perl2JSON($resp->content) . "\n";
         }
@@ -166,7 +175,10 @@ try {
     warn "$e\n";
 };
 
-unlink $opt_lockfile;
-
-
+if (-e $opt_lockfile) {
+    open LF, $opt_lockfile;
+    my $contents = <LF>;
+    close LF;
+    unlink $opt_lockfile if ($contents == $$);
+}