I'm wondering how others are doing this.
For some critical daemons, I use inittab with the respawn option.
I'd like to do something similar with my init scripts, and automatically restart them if their corresponding services crash (but not necessarily all of them).
What is the best approach?
method 1:
Use a custom cron job or inittab script to parse the output of:
Code: Select all
rc-status -cThe inconvenience of this method is that the restart does not necessarily start right after a crash (depends on the cron periodicity setting).
Also, I am not sure every single service crash case is reflected as "crashed" in rc-status -c. Maybe some "crashes" are sometimes reported as "stopped" services? Finally, will "-c" report a crashed service in any runlevel, including the "manual runlevel"?
method 2:
Use a custom cron job or inittab script to parse the output of:
Code: Select all
rc-status -m -C | grep -v '\[ started \]' | cut -f 2 -d ' 'The inconvenience of this method is that I don't know how to tell rc-status to list only the services in the default runlevel. I might also auto-restart a service that was purposely stopped manually. As in method 1, the restart does not necessarily take place right after a crash.
method 3:
Use supervise-daemon.
The huge inconvenience of this method is that Gentoo wiki states that it is still unstable software, requires manually hacking the init.d files of the services you want to supervise, and make sure the service doesn't use its own PID file or forks.
Any ideas?
Despite its disadvantages, method 1 seems to be the easiest to implement and maintain for now.
The supervise-daemon looks interesting, but it's too tedious to set up and maintain.




