Runit


runit is an init scheme for Unix-like operating systems that initializes, supervises, and ends processes throughout the operating system. Runit is a reimplementation of the daemontools process supervision toolkit that runs on many Linux-based operating systems, as well as, the macOS, *BSD, and Solaris operating systems. Runit features parallelization of the start up of system services, which can speed up the boot time of the operating system.
Runit is an init daemon, so it is the direct or indirect ancestor of all other processes. It is the first process started during booting, and continues running until the system is shut down.

Design

Runit focuses on being a small, modular, and portable codebase. Runit is split into three stages: one time initialization, process supervision, and halting or rebooting. While the first and third stages must be adapted to the specific operating system they are running on, the second stage is portable across all POSIX compliant operating systems.
The 3 stages can be configured through 3 executable files named, respectively, 1, 2, and 3.
Stage 2 usually invokes a binary named runsvdir, which is the process responsible of global daemons management: for every daemons it finds in a folder passed to it by argument, it then spawns individual watchdog, each of those starts a daemon and restarts it if it dies. In case a daemon is added or removed, it kills the watchdog or starts a new one.
Executable files with specific names are used to describe the various phases of the daemon's life, it can intercepts signals sent and run specific scripts if they exists, and named pipes are created to expose interfaces to control the daemon.

Usage

Runit can be used either as a drop-in replacement for sysvinit, or as a service supervisor with sysvinit as the parent PID1 process which runs processes specified by the inittab file. The RubyWorks stack of software able to run Ruby on Rails incorporated Runit into its suite. Runit is the default init system for Void and Artix Linux.