How to configure Python Script to run as a daemon

I've found the easiest way to handle applications like this is to install supervisord and then use that to start, monitor, and collect output from the your script.

Here's a sample supervisor config file:

[program:watcher]
command = /usr/bin/python /path/to/watcher.py
stdout_logfile = /var/log/watcher-stdout.log
stdout_logfile_maxbytes = 10MB
stdout_logfile_backups = 5
stderr_logfile = /var/log/watcher-stderr.log
stderr_logfile_maxbytes = 10MB
stderr_logfile_backups = 5