From 6f72b915824240031bebac3ab3caa12fbab6b943 Mon Sep 17 00:00:00 2001 From: Thomas Ernstorfer Date: Mon, 30 Dec 2013 15:35:34 -0800 Subject: [PATCH 1/3] Fixed args for start() call on restart(). --- initd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/initd.py b/initd.py index 029c879..559d0c0 100644 --- a/initd.py +++ b/initd.py @@ -123,7 +123,7 @@ def restart(self, run, exit=None): if os.path.exists(self.pid_file): self.stop(self.pid_file) print 'Starting.' - self.start(run, self.pid_file, self.log_file) + self.start(run, exit=exit) def execute(self, action, run=None, exit=None): From 14ed2fc330bb68b24d6d969248780d88821a5d70 Mon Sep 17 00:00:00 2001 From: Thomas Ernstorfer Date: Mon, 30 Dec 2013 16:04:55 -0800 Subject: [PATCH 2/3] Fix for trying to stop an already stopped daemon. --- initd.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/initd.py b/initd.py index 559d0c0..b73ee3d 100644 --- a/initd.py +++ b/initd.py @@ -6,7 +6,7 @@ from __future__ import with_statement -import logging, os, signal, sys, time +import logging, os, signal, sys, time, errno __all__ = ['start', 'stop', 'restart', 'execute'] @@ -100,8 +100,14 @@ def stop(self, run=None, exit=None): signal to the process with that as its pid. This will also wait until the running process stops running. """ - with open(self.pid_file, 'r') as stream: - pid = int(stream.read()) + try: + with open(self.pid_file, 'r') as stream: + pid = int(stream.read()) + except IOError as ioe: + if ioe.errno != errno.ENOENT: + raise + sys.stdout('Stopped.\n') + return sys.stdout.write('Stopping.') sys.stdout.flush() os.kill(pid, signal.SIGTERM) From 11261742fa0ff2d9ea583ca18bed2dbe7e4c5de1 Mon Sep 17 00:00:00 2001 From: Thomas Ernstorfer Date: Mon, 30 Dec 2013 16:08:47 -0800 Subject: [PATCH 3/3] Oops, fixed wrong namespace. --- initd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/initd.py b/initd.py index b73ee3d..ffc4d11 100644 --- a/initd.py +++ b/initd.py @@ -106,7 +106,7 @@ def stop(self, run=None, exit=None): except IOError as ioe: if ioe.errno != errno.ENOENT: raise - sys.stdout('Stopped.\n') + sys.stdout.write('Stopped.\n') return sys.stdout.write('Stopping.') sys.stdout.flush()