]> git.llucax.com Git - software/pymin.git/commitdiff
Add a default handle_timer() method to InitdHandler that checks the daemon pid.
authorLeandro Lucarella <llucax@gmail.com>
Mon, 29 Oct 2007 02:08:10 +0000 (23:08 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Mon, 29 Oct 2007 02:08:10 +0000 (23:08 -0300)
This is to provide a more accurate running command. It can be extended to
provide a "persist" option to restart the service when it's down.

pymin/services/util.py

index abf30e9ce097956ecf0543b98461da6c4df5abc4..18b7fefc84c4db3511f75f85b3d88a58c1a4c149 100644 (file)
@@ -592,6 +592,15 @@ class InitdHandler(ServiceHandler):
                                 action)
         ServiceHandler.__init__(self, **actions)
 
                                 action)
         ServiceHandler.__init__(self, **actions)
 
+    def handle_timer(self):
+        p = subprocess.Popen(('pgrep', '-f', self._initd_name),
+                                stdout=subprocess.PIPE)
+        pid = p.communicate()[0]
+        if p.wait() == 0 and len(pid) > 0:
+            c._service_running = True
+        else:
+            c._service_running = False
+
 class TransactionalHandler(Handler):
     r"""Handle command transactions providing a commit and rollback commands.
 
 class TransactionalHandler(Handler):
     r"""Handle command transactions providing a commit and rollback commands.