LinuxCommandLibrary

runsv

Start and manage a service

TLDR

Start a runit service as the current user

$ runsv [path/to/service]
copy

Start a runit service as root
$ sudo runsv [path/to/service]
copy

SYNOPSIS

runsv dir

PARAMETERS

dir
    The directory containing the service configuration and scripts to be managed by runsv. This directory typically includes files like 'run', 'log', and potentially other configuration files specific to the service.

DESCRIPTION

The runsv command is a lightweight service supervisor designed to monitor and manage long-running processes, commonly known as daemons, on Unix-like systems.

It's a core component of the daemontools package. runsv is responsible for ensuring that a service is always running. It continuously monitors the service's process and restarts it automatically if it crashes or exits unexpectedly. This provides a robust and reliable way to keep critical services online.

Configuration is handled via a directory structure, where each service has its own directory containing scripts and configuration files that runsv uses to manage the service.

It simplifies service management by providing a standardized way to start, stop, restart, and monitor services, increasing the overall stability and reliability of the system.

CAVEATS

runsv requires that the 'run' script within the service directory *must* execute the service itself; otherwise, runsv will continually restart an exiting 'run' script. Proper logging setup is crucial when using daemontools, as errors within the 'run' script can lead to endless restart loops if not handled correctly. The 'dir' should be a full absolute path.

SERVICE DIRECTORY STRUCTURE

The 'dir' argument to runsv refers to a directory containing service-specific configuration. Key files within this directory include:

  • run: A script that starts the service. runsv executes this script and monitors its process.
  • log: A subdirectory containing logging-related scripts. Often contains a 'run' script to handle log rotation and archiving.

USAGE EXAMPLE

To manage a service defined in the directory '/service/my_app', you would run: runsv /service/my_app. This starts runsv and tells it to monitor and manage the service defined in that directory. The 'sv' command is then typically used to send signals or otherwise control the service.

HISTORY

runsv is part of the daemontools package, created by Daniel J. Bernstein. The initial release aimed to address shortcomings in traditional init systems by providing a more reliable and manageable method for service supervision. Daemontools and therefore runsv gained popularity for their simplicity and effectiveness in keeping critical services running continuously.

SEE ALSO

runsvdir(8), sv(1), svc(8)

Copied to clipboard