[Opensrf-commits] r2070 - trunk/src/python (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Nov 9 13:17:54 EST 2010


Author: dbs
Date: 2010-11-09 13:17:50 -0500 (Tue, 09 Nov 2010)
New Revision: 2070

Modified:
   trunk/src/python/opensrf.py.in
Log:
Enhanced do_start() implementation in Python management script

Unclean shutdowns and fork() misery can create PID files that have
no actual process behind them. Instead of just trusting the PID file, check
for the running PID; if the process is not running, then remove the PID file
and actually start the service.


Modified: trunk/src/python/opensrf.py.in
===================================================================
--- trunk/src/python/opensrf.py.in	2010-11-09 17:54:13 UTC (rev 2069)
+++ trunk/src/python/opensrf.py.in	2010-11-09 18:17:50 UTC (rev 2070)
@@ -113,8 +113,13 @@
         return
 
     if os.path.exists(pidfile):
-        print "* service %s already running" % service
-        return
+        try:
+            pid_fd = open(pidfile, 'r')
+            alive = os.getsid(int(pid_fd.read()))
+            print "* service %s already running" % service
+            return
+        except OSError:
+            os.remove(pidfile)
 
     print "* starting %s" % service
 



More information about the opensrf-commits mailing list