From: dbs Date: Tue, 9 Nov 2010 18:17:50 +0000 (+0000) Subject: Enhanced do_start() implementation in Python management script X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bd3c2f9d5612799c077492e2b574c4d9551d7c66;p=opensrf%2Fbjwebb.git 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. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@2070 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/python/opensrf.py.in b/src/python/opensrf.py.in index bd6c4f0..809946b 100755 --- a/src/python/opensrf.py.in +++ b/src/python/opensrf.py.in @@ -113,8 +113,13 @@ def do_start(service): 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