salt.modules.runit

runit service module (http://smarden.org/runit)

This module is compatible with the service states, so it can be used to maintain services using the provider argument:

myservice:
  service:
    - running
    - provider: runit

Provides virtual service module on systems using runit as init.

Service management rules (sv command):

service $n is ENABLED if file SERVICE_DIR/$n/run exists service $n is AVAILABLE if ENABLED or if file AVAIL_SVR_DIR/$n/run exists service $n is DISABLED if AVAILABLE but not ENABLED

SERVICE_DIR/$n is normally a symlink to a AVAIL_SVR_DIR/$n folder

Service auto-start/stop mechanism:

sv (auto)starts/stops service as soon as SERVICE_DIR/<service> is created/deleted, both on service creation or a boot time.

autostart feature is disabled if file SERVICE_DIR/<n>/down exists. This does not affect the current's service status (if already running) nor manual service management.

Service's alias:

Service sva is an alias of service svc when AVAIL_SVR_DIR/sva symlinks to folder AVAIL_SVR_DIR/svc. svc can't be enabled if it is already enabled through an alias already enabled, since sv files are stored in folder SERVICE_DIR/svc/.

XBPS package management uses a service's alias to provides service alternative(s), such as chrony and openntpd both aliased to ntpd.

salt.modules.runit.add_svc_avail_path(path)

Add a path that may contain available services. Return True if added (or already present), False on error.

path
directory to add to AVAIL_SVR_DIRS
salt.modules.runit.available(name)

Returns True if the specified service is available, otherwise returns False.

name
the service's name

CLI Example:

salt '*' runit.available <service name>
salt.modules.runit.disable(name, stop=False, **kwargs)

Don't start service name at boot Returns True if operation is successfull

name
the service's name
stop
if True, also stops the service

CLI Example:

salt '*' service.disable <name> [stop=True]
salt.modules.runit.disabled(name)

Return True if the named service is disabled, False otherwise

name
the service's name

CLI Example:

salt '*' service.disabled <service name>
salt.modules.runit.enable(name, start=False, **kwargs)

Start service name at boot. Returns True if operation is successful

name
the service's name
start
False : Do not start the service once enabled. Default mode.
(consistent with other service management)

True : also start the service at the same time (default sv mode)

CLI Example:

salt '*' service.enable <name> [start=True]
salt.modules.runit.enabled(name)

Return True if the named service is enabled, False otherwise

name
the service's name

CLI Example:

salt '*' service.enabled <service name>
salt.modules.runit.full_restart(name)

Calls runit.restart()

name
the service's name

CLI Example:

salt '*' runit.full_restart <service name>
salt.modules.runit.get_all()

Return a list of all available services

CLI Example:

salt '*' runit.get_all
salt.modules.runit.get_disabled()

Return a list of all disabled services

CLI Example:

salt '*' service.get_disabled
salt.modules.runit.get_enabled()

Return a list of all enabled services

CLI Example:

salt '*' service.get_enabled
salt.modules.runit.get_svc_alias()

Returns the list of service's name that are aliased and their alias path(s)

salt.modules.runit.get_svc_avail_path()

Return list of paths that may contain available services

salt.modules.runit.get_svc_broken_path(name='*')

Return list of broken path(s) in SERVICE_DIR that match name

A path is broken if it is a broken symlink or can not be a runit service

name
a glob for service name. default is '*'

CLI Example:

salt '*' runit.get_svc_broken_path <service name>
salt.modules.runit.missing(name)

The inverse of runit.available. Returns True if the specified service is not available, otherwise returns False.

name
the service's name

CLI Example:

salt '*' runit.missing <service name>
salt.modules.runit.reload(name)

Reload service

name
the service's name

CLI Example:

salt '*' runit.reload <service name>
salt.modules.runit.remove(name)

Remove the service <name> from system. Returns True if operation is successfull. The service will be also stopped.

name
the service's name

CLI Example:

salt '*' service.remove <name>
salt.modules.runit.restart(name)

Restart service

name
the service's name

CLI Example:

salt '*' runit.restart <service name>
salt.modules.runit.show(name)

Show properties of one or more units/jobs or the manager

name
the service's name

CLI Example:

salt '*' service.show <service name>
salt.modules.runit.start(name)

Start service

name
the service's name

CLI Example:

salt '*' runit.start <service name>
salt.modules.runit.status(name, sig=None)

Return True if service is running

name
the service's name
sig
signature to identify with ps

CLI Example:

salt '*' runit.status <service name>
salt.modules.runit.status_autostart(name)

Return True if service <name> is autostarted by sv (file $service_folder/down does not exist) NB: return False if the service is not enabled.

name
the service's name

CLI Example:

salt '*' runit.status_autostart <service name>
salt.modules.runit.stop(name)

Stop service

name
the service's name

CLI Example:

salt '*' runit.stop <service name>