Usage: subclass the Daemon class and override the run() method
"""
- version = "0.3"
+ version = "0.4"
def __init__(self, pidfile,
stdin='/dev/null',
try:
os.umask(self.umask)
file(self.pidfile, 'w').write('%s\n' % pid)
- #except IOError, wpid_err:
except Exception, wpid_err:
- sys.stderr.write(u'Error trying to write pid file to %s: %s\n' %
- (unicode(self.pidfile, 'utf-8'), wpid_err))
+ sys.stderr.write(u'Error trying to write pid file: %s\n' % wpid_err)
sys.exit(1)
os.umask(0)
atexit.register(self.delpid)
sys.exit(1)
def delpid(self):
- os.unlink(self.pidfile)
+ try:
+ os.unlink(self.pidfile)
+ except OSError as err:
+ message = 'Error trying to remove PID file: %s\n'
+ sys.stderr.write(message % err)
def start(self):
"""
sys.stderr.write(message % self.pidfile)
os.remove(self.pidfile)
else:
- print str(err)
+ sys.stderr.write(err.strerror)
sys.exit(1)
def restart(self):