runit
Manage and supervise processes
TLDR
Start runit's 3-stage init scheme
Shut down runit
SYNOPSIS
While runit itself is the init process (PID 1) and not directly invoked by users, its primary user-facing command for service management is sv.
sv [ -v ] <command> <service_directory_or_name> [...]
PARAMETERS
-v
Enables verbose output, showing more details about the operation.
<command> (e.g., up, down, status)
The action to perform on the service(s). See individual commands below.
<service_directory_or_name>
The path to the service directory (e.g., /etc/service/myservice) or the service name relative to the service directory tree (e.g., myservice).
up
Brings the service up (starts it if down, or signals it to restart if exited).
down
Brings the service down (stops it).
once
Starts the service, but does not restart it if it exits. Supervisor will exit after service does.
cont
Continues a service that is paused.
pause
Pauses a service by sending it a STOP signal.
hup
Sends a HUP signal to the service process.
alrm
Sends an ALRM signal to the service process.
int
Sends an INT signal to the service process.
quit
Sends a QUIT signal to the service process.
1-6
Sends USR1 through USR6 signals to the service process, respectively.
term
Sends a TERM signal to the service process.
kill
Sends a KILL signal to the service process (forcibly terminates).
status
Displays the current status of the specified service(s).
check
Checks if the service is running and properly supervised.
exit
Stops the service and permanently disables its supervision. The supervisor process will exit.
force-exit
Immediately stops the service and permanently disables its supervision, without waiting for the service to terminate cleanly.
shutdown
Attempts to stop all supervised services gracefully. Used during system shutdown.
reload
Sends a HUP signal to the service. If the service exits, it will be restarted. Similar to 'hup' but with restart logic.
restart
Sends a TERM signal to the service, waits for it to exit, and then restarts it. If it doesn't exit, sends KILL.
start
Alias for the 'up' command. Starts the service.
stop
Alias for the 'down' command. Stops the service.
DESCRIPTION
runit is a complete Unix init scheme and service supervision suite, designed for speed, reliability, and minimal resource usage. It functions as a replacement for traditional init systems like SysVinit or systemd, especially in environments prioritizing simplicity and robustness. The core philosophy revolves around "one process per service," where each daemon is managed by a dedicated runit supervisor. This modular approach enhances stability; if a service crashes, runit automatically restarts it, ensuring continuous operation. It typically operates in three stages: the initial boot process managed by runit-init, handling of login prompts (often by runit-getty), and continuous service supervision via the sv program. Services are configured within simple directories, each containing an executable run script that defines how the service starts. This design makes service management straightforward, enabling actions like starting, stopping, reloading, and checking status through the intuitive sv command. Its small footprint and predictable behavior make it a popular choice for servers, embedded systems, and users seeking a less complex alternative to modern init systems.
CAVEATS
runit is an entire init system, not just a single command. The primary user interface for managing services is the sv command. It is not directly compatible with SysVinit or systemd service configurations; services must be specifically structured for runit. While highly reliable, it requires understanding its unique service directory structure and supervision model.
CORE COMPONENTS AND PHILOSOPHY
runit's architecture is built on a few core principles and components:
1. One process per service: Each managed service runs as a single process, supervised by a dedicated supervise daemon.
2. Service Directories: Services are configured in a designated directory (commonly /etc/service/servicename). This directory contains an executable run script to start the service. Optionally, it can include a log/run script for dedicated service logging and a control directory for custom signal handling scripts.
3. Simplicity and Predictability: The tools are small, perform single tasks efficiently, and interact predictably, contributing to high reliability.
4. Automatic Service Restart: The supervisor automatically restarts services that crash or exit unexpectedly, ensuring high availability.
HISTORY
runit was developed by Daniel J. Bernstein (djb) in 2002. It emerged as a lightweight, robust, and fast alternative to then-dominant SysVinit systems. Its design philosophy emphasizes simplicity, security, and reliability through minimal, focused tools and a clear process-per-service model. It has influenced other supervision systems and remains a choice for minimal systems or those seeking alternatives to more complex modern init systems.