... XADADA: content/docs/2016-05-14_runit.md
   2016-05-14 13:06

Runit

Void Linux Wiki [dumped]

runit is the default init system used by Void Linux. runit is a suite of tools which include a PID 1 init as well as a daemontools-compatible process supervision framework, along with utilities which streamline creation and maintenance of services.

runit employs a concept of a service directory, responsible for an individual service, which is a process to monitor, and an optional log service.

Basic Usage

To start, stop or restart a service, run:

# sv up _service_name_ # sv down _service_name_ # sv restart _service_name_ 

To get the current status of a service, run:

# sv status _service_name_ 

To get the current status of all enabled services, run:

# sv status /var/service/agetty-tty1 /var/service/agetty-tty2 /var/service/agetty-tty3 /var/service/agetty-tty4 /var/service/agetty-tty5 /var/service/agetty-tty6 /var/service/dhcpcd /var/service/dropbear /var/service/edge /var/service/nginx /var/service/nmbd /var/service/rsyslogd /var/service/smbd /var/service/supernode /var/service/tor /var/service/transmission-daemon /var/service/udevd /var/service/wpa_supplicant 

Enabling new services

To add a new service for runit to manage, first install the service using xbps:

# xbps-install _service_name_ 

After installing a service, xbps will create the service directory as /etc/sv/service_name To use the service, you will need to create a symlink to the service directory in /var/service:

# ln -s /etc/sv/_service_name_ /var/service/ 

This will automatically start the service in your current runlevel. Once a service is linked it will always start on boot and restart if it stops (unless administratively downed).

Disabling services

To disable a service in the current runlevel, remove the symlink to its service directory from /var/service:

# rm /var/service/_service_name_ 

A service directory requires only one file, an executable named run which is expected to exec a process in the foreground. If the service directory contains a directory named log, a pipe will be opened from the output of the run process in the service directory to the input of the run process in the log directory.

Example: /etc/sv/sshd(8) service

File: /etc/sv/sshd/run

#!/bin/sh ssh-keygen -A >/dev/null 2>&1 # Will generate host keys if they don't already exist [ -r conf ] && . ./conf exec /usr/sbin/sshd -De $OPTS 2>&1 

Note that the process shouldn’t background. When a new service is created, the log and supervise folders are automatically created on first run. Another script “finish” may also be present in the service dir, which runs on shutdown/process stop. Dependent services may be directly started as such:

#!/bin/sh sv start dep_1 sv start dep_2 exec thing -D 

Linking /etc/sv/sshd/ to /var/service/sshd will run the sshd process in the foreground, making sure all output (stderr, stdout) are directed to stdout, which will be piped to the log below (/etc/sv/sshd/log/run):

#!/bin/sh [ -d /var/log/sshd ] || mkdir -p /var/log/sshd exec chpst -u root:adm svlogd -t /var/log/sshd 

The runit-void package currently supports two runlevels: single and default.

Source “Runit - Void Linux Wiki”


2016-05-14 13-00



Комментарии [0] ::

 Высказаться...