Let me first say that pyramid has made writing cli scripts a breeze with pyramid.paster.bootstrap(). I love it!
I am looking to turn some of my scripts into daemon processes. I went to look at how pserve does this, and I noticed that it is not a trivial piece of code. It seems to me that it would be incredibly useful to add a daemonize function that mimics (and slightly builds upon) the behavior seen in pserve so as to make it easy to developers.
I am imagining an interface that looks something like:
daemonize(<start|stop|restart|reload|status>, pid_file_location)
or, more cleanly(?)
daemon_start(pid_file_location)
daemon_stop(pid_file_location)
daemon_restart(pid_file_location)
daemon_reload(pid_file_location)
daemon_status(pid_file_location)
Potential additional enhancements would be to specify the signals used for stop, restart, and reload. I think that these can exist as standalone functions, or, alternatively, it would be easy enough to make a callable DaemonCommand base class. Thoughts?