Runit Operations

Manage runit services.

Facts used in these operations: files.File, runit.RunitManaged, runit.RunitStatus.

runit.auto

Start service automatically by managing the service/down file.

runit.auto(service, auto=True, sourcedir="/etc/sv")
  • service: name of the service to manage
  • auto: whether the service should start automatically
  • sourcedir: where to search for available services

runit.manage

Manage runit svdir links.

runit.manage(service, managed=True, svdir="/var/service", sourcedir="/etc/sv")
  • service: name of the service to manage
  • managed: whether the link should exist
  • svdir: alternative SVDIR
  • sourcedir: where to search for available services

runit.service

Manage the state of runit services.

runit.service(
    service, running=True, restarted=False, reloaded=False, command=None, enabled=None,
    managed=True, svdir="/var/service", sourcedir="/etc/sv",
)
  • service: name of the service to manage

  • running: whether the service should be running

  • restarted: whether the service should be restarted

  • reloaded: whether the service should be reloaded

  • command: custom command to pass like: sv <command> <service>

  • enabled: whether this service should be enabled/disabled on boot

  • managed: whether runit should manage this service

    For services to be controlled, they first need to be managed by runit by adding a symlink to the service in SVDIR. By setting managed=False the symlink will be removed. Other options won’t have any effect after that. Although the <service>/down file can still be controlled with the enabled option.

  • svdir: alternative SVDIR

    An alternative SVDIR can be specified. This can be used for user services.

  • sourcedir: where to search for available services

    An alternative directory for available services can be specified. Example: sourcedir=/etc/sv.local for services managed by the administrator.

runit.wait_runsv

Stateless operation

This operation will always execute commands and is not idempotent.

Wait for runsv for service to be available.

runit.wait_runsv(service, svdir="/var/service", timeout=10)
  • service: name of the service to manage
  • svdir: alternative SVDIR
  • timeout: time in seconds to wait