python-daemonize and upstart
Paul Rudin
paul.nospam at rudin.co.uk
Sat Nov 14 02:32:48 EST 2009
I'm experimenting with the daemon module
<http://pypi.python.org/pypi/python-daemon/> and upstart
<http://upstart.ubuntu.com/>. There's something I don't understand,
which may be more of an upstart issue than a python issue, but I thought
I'd start by posting here.
Here's a test script:
#!/usr/bin/python2.6
import daemon
import time
def work():
count = 0
while True:
with open('/tmp/test.txt', 'a') as f:
f.write(str(count))
f.write('\n')
count += 1
time.sleep(5)
def main():
with daemon.DaemonContext(working_directory='/tmp'):
work()
if __name__ == "__main__":
main()
and here's a testdaemon.conf upstart configuration:
description "test daemon"
expect daemon
chdir /tmp
exec /tmp/testdaemon.py
If I do "sudo start testdaemon" I see the "testdaemon.py" process
starting, and the file '/tmp/test.txt' is being written to every 5
seconds, so everything has kicked off.
The thing I don't understand is why start does not return. I guess it
doesn't think that the process and properly started and daemonized
itself? Quite possibly it's just that I don't understand this stuff
well...
More information about the Python-list
mailing list