How to daemonize servers on Ubuntu?

The existing SysInit system would handle that for you just fine. Ubuntu has docs on what they are doing with these. Yes, they are switching to upstart.


If your programs are running in the foreground, I suggest Runit, which is a replacement for the previously-mentioned daemontools, and is also a replacement for Sys-V style init. On Ubuntu, Runit is available as a package and has the necessary scripts to be started at system boot by Upstart.

We use Runit for all non-system-installed packages, such as Rails applications, so we don't have to manage init scripts; we just pop the startup command in the appropriate 'run' script, and let it go. This simplifies deployment of arbitrary new programs that need to start at boot time, and is a very robust and reliable system, eschewing the need to manage PID and lockfiles, since Runit handles that.


Daemontools is absolutely awesome for this sort of thing. KISS-grade simple, robust, and encourages good practices in related areas (logging, etc).