LinuxCommandLibrary

runsvdir

Start and monitor services from a directory

TLDR

Start and manage all services in a directory as the current user

$ runsvdir [path/to/services]
copy

Start and manage all services in a directory as root
$ sudo runsvdir [path/to/services]
copy

Start services in separate sessions
$ runsvdir -P [path/to/services]
copy

SYNOPSIS

runsvdir [ -P ] dir

PARAMETERS

-P
    If runsvdir is run as a process group leader, this option creates a new session and process group for the svscan child process. This is particularly useful when runsvdir is started by init or a similar process, ensuring svscan operates in its own detached session.

dir
    The path to the directory that runsvdir will manage. This directory must contain the subdirectories for the services to be supervised. runsvdir will execute svscan within this specified dir.

DESCRIPTION

runsvdir is a utility from the runit supervision suite, designed to manage a directory containing service supervision directories. It specifically ensures that the svscan process is continuously running within the specified directory.

When svscan is active, it monitors its designated directory (e.g., /etc/service) for subdirectories. Each subdirectory represents a service (e.g., /etc/service/myservice) and should contain a run script and optionally a log subdirectory. svscan then launches a supervise process for each service, which is responsible for keeping the service's run script executing and restarting it upon termination or crash.

By acting as a reliable parent for svscan, runsvdir plays a crucial role in maintaining system services robustly. It's often used as the root of the service supervision tree, ensuring continuous uptime and automated recovery of crashed services, making it a fundamental component for fault-tolerant system management.

CAVEATS

runsvdir expects the svscan executable to be available in the system's PATH or at a predefined location (e.g., /command/svscan for runit systems).

It is designed to be run as a daemon, often as the direct child of the system's init process. If svscan exits, runsvdir will also terminate, indicating a critical failure in the service supervision tree.

PROCESS MANAGEMENT ROLE

On systems utilizing runit, runsvdir often takes on a critical role in process management, sometimes even acting as PID 1 (the init process) itself, or being directly spawned by it. It serves as the primary guardian of the svscan process, which is essential for ensuring all other system services are kept alive and automatically restarted upon failure.

INTEGRATION WITH INIT SYSTEMS

Many runit-based Linux distributions configure their init system to execute runsvdir early in the boot sequence, typically directing it to manage a central services directory (e.g., /etc/service). This tight integration ensures that service supervision begins as soon as the system starts, providing a robust and self-healing environment for system services.

HISTORY

runsvdir is a core component of the runit init scheme and service supervision system, created by Gerrit Pape. runit emerged as a lightweight, reliable, and fast alternative to traditional sysvinit and the daemontools suite. runsvdir specifically addresses the need to reliably launch and monitor the main svscan process, which in turn manages all individual services. Its development is rooted in the principles of simplicity and robustness, ensuring that the system's service supervision remains active and functional at all times.

SEE ALSO

svscan(8), sv(8), supervise(8), runit(8), init(8)

Copied to clipboard