runit is a daemontools clone by Gerrit Pape with good integration into Debian.

We consider it exotic, because it doubles some functionality of init-systems like sysvinit or systemd and is not know to be used widely.

Installation

Debian default

sudo apt-get install runit-systemd

For compatibility create /service:

sudo ln -s /etc/service /service

Alternative

runit installs as local software as slashpackage and can be compiled with diet libc. See the install and diet libc instructions on Gerrits page.

We have created an equivs runit surrogate package, which satisfies the dependendies of the runit-systemd and the socklog-run package.

To integrate the source-built runit with Debian:

  1. Install as indicated
  2. Download, than install the surrogate:
    dpkg -i runit-surrogate_1.0_all.deb
  3. apt-get install runit-systemd

/service is created as directory by runit-surrogate.

If not:

sudo install -d -m 2775 -o root -g staff /service

Notes / ToDo:

  • compiling seems to have hickups, cd compile && make clean; cd .. helps
  • the runit-surrogate package does not create the /service directory

Usage

Services are set up as directories anywhere on the filesystem. The directory is linked to /service which makes all active services visible in one place.

Debin installs runit supervised service directories – like socklog – in /etc/sv. We avoid this directory for locally installed services to avoid name clashes and typically use /etc as base directory.

The minimal requirement to set up is an executable file named run in the directory /etc/servicename, which runs the service in the foreground.

Services typically feature a dedicated log service which is set up in the directory /etc/servicename/log

Activate a service

Change to the /etc/servicename directory.

ln -s `pwd` /service

It is started up within a second or so.

Deactivate a service

Change to the /service/servicename directory.

rm `pwd`
sv -x .

Manage a service

man sv

Monitor operation of a service

tail -F /service/<servicename>/log/main/current

Move supervise directories and make them work with staff

Debian and FHS do not want /service/servicename/{,log/}supervise directories to be on /etc, because /etc is considered read-only.

The following ?shnippet helps to move them to Debians preferred location and links them back to the service directory.

SV=path_to_service_directory
---
SVDIR=$SV
SV=$(basename $SVDIR)
cd $SVDIR
sudo chgrp -R staff supervise
sudo chmod -R g+rw supervise
sudo chmod g+sx supervise
sudo mv supervise /var/lib/supervise/$SV
sudo ln -s /var/lib/supervise/$SV supervise
cd log
sudo chgrp -R staff supervise
sudo chmod -R g+rw supervise
sudo chmod g+sx supervise
sudo mv supervise /var/lib/supervise/$SV.log
sudo ln -s /var/lib/supervise/$SV.log supervise
cd $SVDIR