From: Leandro Lucarella Date: Mon, 29 Oct 2007 02:08:10 +0000 (-0300) Subject: Add a default handle_timer() method to InitdHandler that checks the daemon pid. X-Git-Url: https://git.llucax.com/software/pymin.git/commitdiff_plain/2e752427c5e056dd913e74d02a9e890731af9d92?ds=sidebyside;hp=--cc Add a default handle_timer() method to InitdHandler that checks the daemon pid. 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. --- 2e752427c5e056dd913e74d02a9e890731af9d92 diff --git a/pymin/services/util.py b/pymin/services/util.py index abf30e9..18b7fef 100644 --- a/pymin/services/util.py +++ b/pymin/services/util.py @@ -592,6 +592,15 @@ class InitdHandler(ServiceHandler): 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.