Scan directories

A scan directory is a directory containing a list of service directories, or symbolic links pointing to service directories.

A scan directory represents a list of services that are supposed to be supervised. Running s6-svscan on this scan directory launches a supervision tree: every service listed in the scan directory will be supervised.

There is normally only one scan directory per system, although nothing prevents a system administrator from having more. daemontools traditionally uses /service, and runit traditionally uses /etc/service. s6 does not care where your scan directory is, but I would advise /service for compatibility with daemontools. Depending on your installation, /service could be a symbolic link and point to a place either in a RAM filesystem or in /var.

Where and how to build a scan directory

Opinions and practices differ.

It is generally accepted that the place where you store all your service directories (your "service repository") should not be used as a scan directory - for a simple reason: you might want to have service directories for more services than what you want to start at any given time. In other words, your scan directory will be a subset of your service repository, so you cannot just run s6-svscan on every service you have a service directory for. So, the first thing is to separate your service repository, which is just a storage place for all the services you might want to manage someday, and your scan directory, which is a directory representing all the services that you are currently managing.

Service repository

Where to store your service repository is purely a matter of personal preference. You just have to be aware that s6-supervise needs writable supervise and event subdirectories in a service directory it monitors.

Scan directory

Where and how to build your scan directory depends heavily on your boot system - and on your personal preference too.

Standard daemontools and runit installations like to have a fixed scan directory containing symlinks to service directories located in the service repository. In other words, the service repository contains the real working copies of the service directories. This works, as long as:

My own recommendation would be to have working copies of the service directories entirely separate from the service repository. The service repository can be safely stored on the root filesystem, and the needed directories copied to a RAM filesystem at boot time. The scan directory can be either the place where the working copies are written, or another directory containing symlinks to those working copies. (The latter is useful if you are using the -t option to s6-svscan with a nonzero argument: copying a directory is not atomic, but making a symlink is, so there is no risk of your scanner finding a directory while it is being copied - which could result in s6-supervise getting the wrong information and not managing the service properly.)

An example: