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.

Requirements

Installation

See the install and diet libc instructions on Gerrits page.

?shnippet:

VER=2.1.2

PATH=/opt/diet/bin:$PATH

cd /package
curl -OL http://smarden.org/runit/runit-$VER.tar.gz
tar xzf runit-$VER.tar.gz
cd admin/runit-$VER
echo 'diet -Os gcc -O2 -Wall' >src/conf-cc
echo 'diet -Os gcc -s -Os -pipe' >src/conf-ld
package/install

Alternative for Debian

sudo apt-get install runit-systemd

For runit/supervise compatibility create /service:

sudo ln -s /etc/service /service

Set up

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
sudo true

# Install runit surrogate package
cd /opt/equivs/runit
sudo dpkg -i runit-surrogate_1.0_all.deb

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

sudo apt-get install runit-systemd

# Create Debian compatibility link

sudo ln -nfs /service /etc/service

Notes / ToDo:

  • compiling seems to have hickups, cd compile && make clean; cd .. helps

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