Runit

runit is an init replacement with service monitoring. It can be used in conjunction with OpenRC as an alternative to sysvinit.

PID 1 &mdash; init replacement
Runit can be used as the system init. To do this, simply add init=/sbin/runit-init to your bootloader's command line and reboot. You can leave sysvinit installed and go back to it at any time by reverting the change.

Out of the box, runit-init has a very minimal configuration which will only get you to a console login. Although it would be optimal to have all your daemons started up in a single consistent way, you're free to mix and match between runit and OpenRC as you like. Your initscripts can be found in the "default" runlevel, which can be started automatically on boot with the existing "local" service:

If you prefer to do it manually:

Init Stage 1
This stage should take care of system initialization and be short and sane to avoid any possible system or comand hang because there is no safety net in this stage&mdash;holding the power button or unpluging the power cable would be the only workaround.

Init Stage 2
This stage should exec into runsvdir (supervisor utility) in order to have PID 2 hold the supervised process tree.

See the forums thread to know the details about why boot and default run levels are included in stage 2 rather in stage 1. Simply put, CTRL-ALT-DEL signal is inactive on stage 1, so this will prevent to have to hold the power switch in case something goes wrong and hang when doing further system initialization&mdash;an extended boot run level.

And lastly, copying /service/ directory to a tmpfs based filesystem would prevent unecessary disk seeks related to runtime service supervision. And this is a sane default becasue many init systems&mdash;like OpenRC&mdash;does this as well.

Init Stage 3
Stage should take care of system halt and reboot.

See Runit for another OpenRC friendly implementation.

SysVinit Reboot and Shutdown Compatibility Service
Runit isn't directly compatible with sysvinit's "telinit", "halt", "poweroff", "reboot" and "shutdown" commands, however many programs (e.g. desktop environments) expect to be able to call some of these. It's possible to emulate the interface they need with a simple script.

If all else fails, use runit-init 0 to shut down or runit-init 6 to reboot.

As a system service
Runit can supervise processes without running as init, or even necessarily as root:

OpenRC can start this for you using /etc/init.d/local (see /etc/local.d/README for more details):

Process Supervision
Like Daemontools, Daemontools-encore or S6 for that matter, Runit can be used to supervise long lived processes, or rather daemons to be precise, be it used as PID 1 or not. This usage will ensure process management easy with sv utility if need be. Daemons would be restarted automatically if necessary after a crash or by an accidental signal mis-usage. So, keeping a few processes,&mdash;like SSH daemon,&mdash;alive becomes an easy task. Just keep in mind that taking care of stage 1, 2 and 3 (system initialisation, normal functional state and system halt respectively) should be considered seriously when using runit-init as PID 1. This is especially easy when using OpenRC power and flexibility for such an easy&mdash;in this case&mdash;task. See the following sub-section for more info on usable implementaion or the forums thread for a variation of it.

This latter use case,&mdash;bypassing SysVinit init,&mdash;and its treatment is extatly similar to what should be done whith S6.

External Resources

 * Arch Linux Wiki
 * Gentoo Forums
 * supervision-scripts: a large, modular collection of scripts that can be used with runit.
 * Supervision Scripts Framework with an OpenRC friendly stage 1, 2, and 3 for Runit