D. J. Bernstein
UNIX
daemontools

The svscan program

svscan starts and monitors a collection of services.

Interface

svscan starts one supervise process for each subdirectory of the current directory, up to a limit of 1000 subdirectories. svscan skips subdirectory names starting with dots. supervise must be in svscan's path.

If a subdirectory sub is sticky, svscan starts a pair of supervise processes, one for sub, one for sub/log, with a pipe between them. svscan needs two free descriptors for each pipe.

Every five seconds, svscan checks for subdirectories again. If it sees a new subdirectory, it starts a new supervise process. If it sees an old subdirectory where a supervise process has exited, it restarts the supervise process. In the sticky case it reuses the same pipe so that no data is lost.

svscan is designed to run forever. If it has trouble creating a pipe or running supervise, it prints a message to stderr; it will try again a minute later.

If svscan is given a command-line argument, it switches to that directory when it starts.

The /service directory

Normally svscan is started at boot time in a new /service directory. To set this up (under version 0.70 or above), first create /service as root:
     mkdir /service
     chmod 755 /service
Then put
     csh -cf 'svscan /service &'
into your system's boot scripts, typically /etc/rc.local or /etc/init.d/boot. The system's boot path must not contain ., and it must contain the directory where svscan is installed. If it doesn't, set your favorite path explicitly:
     env - PATH=/usr/local/bin:/usr/sbin:/usr/bin:/bin csh -cf 'svscan /service &'
Reboot now, and verify that svscan is running.

To install a new service, make a symbolic link from /service/sub to a directory elsewhere in the filesystem. svscan will spot the link within five seconds and will start a supervise process, or two supervise processes if sub is sticky. You can then use svc on /service/sub to control the service.

Other service-monitoring tools

SVR4-style init programs run daemons listed in /etc/inittab.

SUN's sac program runs ``port monitors'' listed in /etc/saf/_sactab.