I'm looking into different services that help keep processes up and running (auto-restart in the event of a crash). Which ones do you prefer and what are your commends/suggestions? Here are a few methods I've found:
- respawn in /etc/inittab
- supervise with daemontools
- runit
- upstart
- monit
Personally, I had a bad experience with monit not properly respawning processes so I have to recommend against it. I'm currently using daemontools and it's working quite well so far.
daemontools is indeed well proven; the license isn't even problematic anymore, I don't think.
And its FAQ compares it to inittab, which you asked about.
If you want simple, I'd go with runit. It will restart the service once a second until it is consistently up, can replace scripts in /etc/init.d with a tiny bit of handywork, and has consistent handling all the way around.
The only shortcoming I've had is figuring out single-shot always-on services (services that "start" but in reality exit while leaving a flag that they are "running", i.e.
/etc/init.d/networking
really isn't a service but acts like one), there's a bit of hand-holding that goes with it to get that behavior. Most people introduce a secondary tool to suspend the run script from terminating, or infinite-loop it with asleep
, etc. so that it won't exit the script. When you issuesv stop <service>
it then TERMinates the shell and everything proceeds "as normal".launchd solves this problem and many more. According to the wikipedia article:
It's prolific in the mac world, but it is open source and there's no reason you can't use it in linux. Ubuntu considered using it but the license was incompatible at the time (it has since been changed to the Apache license).
Quagga routing suite has watchquagga, which is tailored to that suite's needs. Not sure if it can be used with any generic daemon.