Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed args for start() call on restart(). #1

Merged
merged 3 commits into from
Jan 2, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions initd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -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.write('Stopped.\n')
return
sys.stdout.write('Stopping.')
sys.stdout.flush()
os.kill(pid, signal.SIGTERM)
Expand All @@ -123,7 +129,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):
Expand Down