s6
Software
www.skarnet.org

The s6-svscan program

s6-svscan starts and monitors a collection of s6-supervise processes, each of these processes monitoring a single service. It is designed to be either the root or a branch of a supervision tree.

Interface

     s6-svscan [ -d notif ] [ -X consoleholder ] [ -c max | -C services_max ] [ -L name_max ] [ -t rescan ] [ scandir ]

Options

Signals

s6-svscan has special handling for the following signals:

Signals that are not in the above list are not caught by s6-svscan and will have the system's default effect.

The behaviour for the first three signals in the list is always fixed:

The behaviour for the rest of the list is configurable: on receipt of a SIGFOO, s6-svscan will try to run an executable .s6-svscan/SIGFOO file. For instance, a .s6-svscan/SIGTERM executable script will be run on receipt of a SIGTERM. If the file cannot be found, or cannot be executed for any reason, the default behaviour for the signal will be applied. Default behaviours are:

The reaper

Upon receipt of a SIGCHLD, or an s6-svscanctl -z command, s6-svscan runs a reaper routine.

The reaper acknowledges (via some wait() function), without blocking, every terminated child of s6-svscan, even ones it does not know it has. This is especially important when s6-svscan is run as process 1.

If the dead child is an s6-supervise process watched by s6-svscan, and the last scan flagged that process as active, then it is restarted one second later.

The scanner

Upon receipt of a SIGALRM or a s6-svscanctl -a command, s6-svscan runs a scanner routine. (It also runs it every rescan milliseconds if the -t option has been given.)

The scanner scans the current directory for subdirectories (or symbolic links to directories), which must be service directories. It skips names starting with dots. It will not create services for more than max subdirectories.

For every new subdirectory dir it finds, the scanner spawns a s6-supervise process on it. If dir/log exists, it spawns an s6-supervise process on both dir and dir/log, and maintains a never-closing pipe from the service's stdout to the logger's stdin. This is starting the service, with or without a corresponding logger. Every service the scanner finds is flagged as "active".

The scanner remembers the services it found. If a service has been started in an earlier scan, but the current scan can't find the corresponding directory, the service is then flagged as inactive. No command is sent to stop inactive s6-supervise processes (unless the administrator uses s6-svscanctl -n or a SIGHUP), but inactive s6-supervise processes will not be restarted if they die.

Notes