DINIT(8)

NAME
dinit - supervise processes and manage services

SYNOPSIS

dinit [-s|--system|-u|--user] [-d|--services-dir dir] [-p|--socket-path path] [-e|--env-file path] [-l|--log-file path] [service-name...]

DESCRIPTION
Dinit is a process supervisor and service manager which can also function as a system init process. It has a small but functional feature set, offering service dependency handling, parallel startup, automatic rate-limited restart of failing processes, and service control functions. Dinit can be run as a system instance (when run as the root user or when specified via command line parameter) or as a user instance. This affects the default paths used to locate certain files. When run as PID 1, the first process, Dinit acts as a system manager and shuts down or reboots the system on request (including on receipt of certain signals). This is currently fully supported only on Linux. See RUNNING AS SYSTEM MANAGER / PRIMARY INIT. Dinit reads service descriptions from files located in a service description directory, normally one of /etc/dinit.d, /usr/local/lib/dinit.d or /lib/dinit.d for the system instance or just $HOME/dinit.d when run as a user process. See SERVICE DESCRIPTION FILES for details of the service description format.

OPTIONS

-d dir, --services-dir dir
    Specifies dir as the directory containing service definition files, can be set multiple times. Default directories are not searched for services when this option is provided. If not specified, the default is $HOME/dinit.d or, for the system service manager, each of /etc/dinit.d/fR, /usr/local/lib/dinit.d, and /lib/dinit.d (searched in that order).

-e file, --env-file file
    Read initial environment from file. For the system init process, the default is /etc/dinit/environment; see FILES.

-p path, --socket-path path
    Specifies path as the path to the control socket used to listen for commands from the dinitctl program. The default for the system service manager is usually /dev/dinitctl (but can be configured at build time). For a user service manager the default is $HOME/.dinitctl.

-l path, --log-file path
    Species path as the path to the log file, to which Dinit will log status and error messages. Note that when running as the system service manager, Dinit does not begin logging until the log service has started. Using this option inhibits logging via the syslog facility, however, all logging messages are duplicated as usual to the console (so long as no service owns the console).

-s, --system
    Run as the system service manager. This is the default if invoked as the root user. This option affects the default service definition directory and control socket path.

-m, --system-mgr
    Run as the system manager (perform operations directly related to machine startup and shutdown). This is the default when running as process ID 1. The main user-visible effect of this option is to invoke the shutdown program when a shutdown is requested (and after all services have stopped), and to provide some basic support for system recovery in case the boot service (or other specified service) cannot be started.

-u, --user
    Run as a user. This is the opposite of --system, and is the default if not invoked as the root user.

-o, --container
    Run in "container mode", i.e. do not perform system management functions (such as shutdown/reboot). The dinit daemon will simply exit rather than executing the shutdown program.

-q, --quiet
    Run with no output to the terminal/console. This disables service status messages and sets the log level for the console log to NONE.

--help
    Display brief help text and then exit. --version Display version number and then exit.

service-name
    Specifies the name of a service that should be started (along with its dependencies). If none are specified, defaults to boot (which requires that a suitable service description for the boot service exists). Note: on Linux, if dinit is running as PID 1 and with UID 0, it will ignore service names provided on the command line, other than "single", unless they appear after a "-o" or "-m" options (or their long forms). This is to filter arguments that were intended for the kernel and not for init. If running in a container, the "-o" option should be used regardless and will inhibit this filtering for any subsequent service names.

SERVICE DESCRIPTION FILES
Service description files specify the parameters of each service. They are named for the service they describe, and are found in /etc/dinit.d for a system instance or $HOME/dinit.d for a user instance. Service description files are read by Dinit on an "as needed" basis. Once a service description has been read the configuration can be altered in limited ways via the dinitctl(8) program. See dinit-service(5) for details of the format and available parameters.

SPECIAL SERVICE NAMES
There are two service names that are "special" to Dinit. The boot service is the service that Dinit starts by default, if no other service names are provided when it is started. The recovery service is a service that Dinit will offer to start if boot appears to fail (that is, if all services stop without a shutdown command having been issued), when Dinit is running as system manager.

OPERATION
On starting, Dinit starts the initial service(s) as specified on the command line. Starting a service also causes the dependencies of that service to start, and any service processes will not be launched until the dependencies are satisfied. Similarly, stopping a service first stops any dependent services. During execution, Dinit accepts commands via a control socket which is created by Dinit when it starts. This can be used to order that a service be started or stopped, to determine service status, or to make certain configuration changes. See dinitctl(8) for details. Dinit attempts to check for the existence of an already-active socket first, and will refuse to start if one exists. Unfortunately, this check cannot be done atomically, and should not be relied upon generally as a means to avoid starting two instances of dinit. Process-based services are monitored and, if the process terminates, the service may be stopped or the process may be re-started, according to the configuration in the service description. Once all services stop, the dinit daemon will itself terminate (or, if running as PID 1, will perform the appropriate type of system shutdown).

  CHARACTER SET HANDLING
Dinit does no character set translation. Dinit's own output is in the execution character set as determined at compilation, as is the interpretation of input. Service names (and other user-defined inputs) are interpreted as byte sequences and are output as they were read. In general, modern systems use the UTF-8 character set universally and no problems will arise; however, systems configured to use other character sets may see odd behaviour if the input character set does not match the output character set, or if either input or output character sets are not a superset of the execution character set.

  RUNNING AS SYSTEM MANAGER / PRIMARY INIT
Running as the system manager (primary init) is currently supported only on Linux. When run as process ID 1, the dinit daemon assumes responsibility for system shutdown and restart (partially relying on external utilities which are part of the Dinit distribution). When not running as process ID 1, dinit assumes responsibility only for service management. System shutdown or restart need to be handled by the primary init, which should start dinit on normal startup, and terminate dinit before shutdown, by signalling it and waiting for it to terminate after stopping services (possibly by invoking dinitctl shutdown).

FILES

/etc/dinit/environment
    Default location of the environment file for Dinit when run as a system instance (for user instances there is no default). Values are specified as NAME=VALUE, one per line, and add to and replace variables present in the environment when Dinit started. Lines beginning with a hash character (#) are ignored.

SIGNALS

When run as a system manager, SIGINT stops all services and performs a reboot (on Linux, this signal can be generated using the control-alt-delete key combination); SIGTERM stops services and halts the system; and SIGQUIT performs an immediate shutdown with no service rollback.

When run as a user process or system service manager only, SIGINT and SIGTERM both stop services and exit Dinit; SIGQUIT exits Dinit immediately.

SEE ALSO
dinitctl(8), dinit-service(5), dinitcheck(8).

AUTHOR
Dinit, and this manual, were written by Davin McCall.