Add some error checking when starting Linux daemons.

This commit is contained in:
Lance Edgar 2014-04-06 20:43:17 -07:00
parent 4f2976a9d4
commit f879487932

View file

@ -91,6 +91,12 @@ class Daemon(object):
# Start the daemon # Start the daemon
if daemonize: if daemonize:
# Make sure the pidfile will be writable.
folder = os.path.dirname(self.pidfile)
if not os.path.exists(folder):
os.makedirs(folder)
if not os.access(folder, os.W_OK):
raise RuntimeError(u"Cannot write to folder: {0}".format(folder))
self.daemonize() self.daemonize()
self.run() self.run()