scripts/scriptmgr.py: ignoring stale pid files when starting scripts
authormartinko <gamato@users.sf.net>
Wed, 7 Sep 2011 08:52:08 +0000 (10:52 +0200)
committerMarko Kreen <markokr@gmail.com>
Wed, 7 Sep 2011 12:58:31 +0000 (14:58 +0200)
scripts/scriptmgr.py

index 03b3aa310b0b32c47d72dc5958df27d60be1a535..0eef052934ad69e390f21d6068cd3e308051939a 100755 (executable)
@@ -157,7 +157,7 @@ class ScriptMgr(skytools.DBScript):
             svc = job['service']
             if job['disabled']:
                 name += "  (disabled)"
-            
+
             if not pidfile:
                 print(" pidfile? [%s] %s" % (svc, name))
             elif os.path.isfile(pidfile):
@@ -184,8 +184,11 @@ class ScriptMgr(skytools.DBScript):
             self.log.warning("No pidfile for %s cannot launch")
             return 0
         if os.path.isfile(pidfile):
-            self.log.warning("Script %s seems running" % job_name)
-            return 0
+            if skytools.signal_pidfile(pidfile, 0):
+                self.log.warning("Script %s seems running" % job_name)
+                return 0
+            else:
+                self.log.info("Ignoring stale pidfile for %s" % job_name)
         cmd = "%(script)s %(config)s %(args)s -d" % job
         res = os.system(cmd)
         self.log.debug(res)
@@ -286,4 +289,3 @@ class ScriptMgr(skytools.DBScript):
 if __name__ == '__main__':
     script = ScriptMgr('scriptmgr', sys.argv[1:])
     script.start()
-