From ArchWiki
Revision as of 15:11, 24 April 2011 by Bougyman (Talk | contribs) (Created page with "{{i18n|Systemd}} Category: Daemons and system services (English) Runit is a process supervisor. It includes runit-init, which can replace sysv's init as pid1, or can be run...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Runit is a process supervisor. It includes runit-init, which can replace sysv's init as pid1, or can be run from inittab or your init system of choice. Runit's simple collection of tools can be used to build flexible dependency structures and distributed systems, or blazing fast parralel runlevel changes (including the initial boot).

See G. Pape's Runit Page for a complete description, but follow the installation instructions below for your Arch system.


To replace init with runit-init

  • install runit-run-git from the AUR
  • choose/create a default runlevel (see Run Levels)
  • reboot

If you just want to get your feet wet and not replace init just yet, runit-dietlibc can be installed side-by-side with the regular Arch initscripts, providing just process supervision of those services you put in /var/service.

  • install runit-dietlibc from the AUR
  • start runsvdir /var/service using your current init scheme (inittab/rc.local/systemd, whatever)

To see a wide variety of services built for runit's style of supervision, install the runit-services package and see /etc/runit/runsvdir/all

Using runit

The Tools

  • sv - used for controlling services, getting status of services, and dependency checking.
  • runsv - supervises a process, and optionally a log service for that process.
  • svlogd - a simple but powerful logger, includes auto-rotation based on different methods (time, size, etc), post-processing, pattern matching, and socket (remote logging) options. Say goodbye to logrotate and the need to stop your services to rotate logs.
  • runsvchdir - changes service levels (runlevels, see below).
  • runit-init - PID 1, tiny, does almost nothing, dietlibc staticly compiled. Just what you want your PID 1 to be.

See the manpages for usage details not covered below.

Run Levels and Service Directories

Runit uses directories of symlinks to specify runlevels, other than the 3 main ones, which are defined in /etc/runit/1, 2, and 3. 1 bootstraps the system, 2 starts runsvdir on /service, and 3 stops the system. While in run level 2, you are not contstrained to any amount service levels (equivalent to runlevels in sysvinit). You can runschdir to any directory (full of service directory symlinks) you've made in /etc/runit/runsvdir/. This becomes very handy in cases where you have an HA (Failover) setup, and you have one machine that can take over services for many other machines, simply by runsvchdir <theservicedir>. You can also run trees of dependent service levels by having user-level supervision directories. See User Level Services below.

General Use

For convenience I'll be using /service as the service directory in these examples. Since this has not been accepted by FHS, it is only made available as a symlink in the runit-run-git package. This allows importing of /service scripts written by others without as much fuss. If you only install runit-dietlibc, you would use /var/service as your service directory, or make the /service symlink to /var/service yourself.

Listing running services


Services should live in /etc/sv; however, the runit-services package puts a bunch of common ones in /etc/runit/runsvdir/all. We're working to replace/convert these to /etc/sv where they belong.

Create and Start a service:


Stops a service immediately (would still start on next boot):


Restarts a service:


Reloads a service:


Shows status of a service including whether it is running or not:


Stops a service, and disables it (won't start next boot):


Refer to man sv for more details.

Notice that you need to use the full name of a service file. E.g., in order to restart the avahi daemon, issue:

Shut down the system


Reboot the system


We've symlinked /sbin/runit-init to /sbin/init in runit-run-git, so as not to have to change grub stuff. The original sysvinit can be started (even after a runit-run-git install) with init=/sbin/init.sysv appended to your kernel command line.

User Level Services

You can extend the supervision tree by starting a runsvdir as a specific user, giving that user control of their own supervise tree.