Daemontools is a collection of tools for managing long-running processes. It's brilliant for keeping daemons alive -- if one dies, Daemontools simply restarts it. Unfortunately, the Ubuntu package is a bit broken because it relies on /etc/inittab, and Ubuntu hasn't used that file for a long time. Here's how to install Daemontools and fix the problem.
Installing Daemontools
This part is easy:
sudo apt-get install daemontools
Done. Unfortunately, it won't start after a reboot, which is rather the point of a process supervisor. The daemontools-run package is supposed to handle startup, but it relies on the traditional init system -- and Ubuntu uses Upstart instead.
Make Daemontools run at system startup
Create the file /etc/event.d/svscanboot with the following content:
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
respawn
exec /usr/bin/svscanboot
You'll also need to create the service directory, since the Ubuntu-packaged version of Daemontools looks for service definitions here:
mkdir /etc/service
Now tell Upstart to start the process:
sudo initctl start svscanboot
Other distributions
Plenty of other distributions use Upstart instead of init, so the fix is similar. For Fedora Core 9 and later, see the Fedora Daemontools guide and this Upstart configuration walkthrough.