Fri, 17 Dec 2004

restartd, a Process Monitor-and-Restart Daemon

Restartd is a daemon for checking your running and not
running processes. It reads the /proc directory in every n
secs and does a POSIX regexp on the process names. You can
execute a script/program if the process is not or it is running.

In general, I don't like automated systems that restart processes. If a process dies unexpectedly, there is a problem that needs to be addressed by a human. Automatically restarting processes that randomly die makes it too easy to ignore the underlying problem.

In the case of clamd, the ClamAV daemon, I have acquiesced because I cannot figure out why it dies randomly every month or two, and have installed restartd. The best thing about restartd is it's simplicity. It reads /proc/*/cmdline every n seconds and compares each command with the list of processes defined in it's config file. I have it configured to monitor clamd, spamd, and our in-house Exim log-to-database utility, exidblog, and to call the appropriate init script to restart a process if it's not running.

The current version of restartd in Debian Sarge (and Sid), 0.1.a-3, is a bit buggy in that it will fail to restart services if it is started from an interactive session once the session is closed. Based on suggestions and code by Glen Turner, I've patched restartd to redirect stdin/stdout/stderr to /dev/null, change the working directory to /, and disassociate from the controlling terminal. I've made the patched Debian package available for download.

tech | Comments | Permanent Link

The state is that great fiction by which everyone tries to live at the expense of everyone else. - Frederic Bastiat