runit is the default init system used by Void Linux. runit is a suite of tools which include a PID 1 init as well as a daemontools-compatible process supervision framework, along with utilities which streamline creation and maintenance of services.
runit employs a concept of a service directory, responsible for an individual service, which is a process to monitor, and an optional log service.
To start, stop or restart a service, run:
# sv up service_name # sv down service_name # sv restart service_name
To get the current status of a service, run:
# sv status service_name
To get the current status of all enabled services, run:
# sv status /var/service/*
Enabling new services
Void Linux provides service directories for most daemons in
/etc/sv/, to enable a service you will need to create a symlink to the service directory in
# ln -s /etc/sv/service_name /var/service/
This will automatically start the service in your current runlevel. Once a service is linked it will always start on boot and restart if it stops (unless administratively downed).
To keep a enabled service from starting automatically at boot, create a file named
down in the service directory.
# touch /etc/sv/service_name/down
To disable a service in the current runlevel, remove the symlink to its service directory from
# rm /var/service/service_name
Void runit directories
/var/service— always linked to the currently active runlevel - all entries in /var/service are considered 'active' services (and by default, are started upon linking)
/etc/sv— directory containing subdirectories of available service files usually placed by xbps
/etc/runit/runsvdir— directory containing all available runlevels
Service directory layout
A service directory requires only one file, an executable named run which is expected to exec a process in the foreground. If the service directory contains a directory named log, a pipe will be opened from the output of the run process in the service directory to the input of the run process in the log directory.
Example: /etc/sv/sshd(8) service
#!/bin/sh ssh-keygen -A >/dev/null 2>&1 # Will generate host keys if they don't already exist [ -r conf ] && . ./conf exec /usr/sbin/sshd -De $OPTS 2>&1
Note that the process shouldn't background. When a new service is created, the log and supervise folders are automatically created on first run. Another script "finish" may also be present in the service dir, which runs on shutdown/process stop. Dependent services may be directly started as such:
#!/bin/sh sv start dep_1 sv start dep_2 exec thing -D
/var/service/sshd will run the sshd process in the foreground, making sure all output (stderr, stdout) is directed to stdout, which will be piped to the log below (/etc/sv/sshd/log/run):
#!/bin/sh [ -d /var/log/sshd ] || mkdir -p /var/log/sshd exec chpst -u root:adm svlogd -t /var/log/sshd
The runit-void package currently supports two runlevels: single and default.
- single: it just runs
sulogin(8)and the necessary steps to rescue your system.
- default: The default run level. default runs all services linked in /var/service/ (aka multi-user).
- smarden.org — Official runit documentation