According to the runit-scripts
(tarball)
a minimal skeleton service (using Alpine Linux) looks like:
#!/usr/bin/env sh
# /etc/sv/skeleton/run
set -eu
exec 2>&1
COMMAND=daemon
USER=root
exec /usr/bin/chpst -u ${USER} ${COMMAND}See also:
#!/usr/bin/env sh
# /etc/sv/skeleton/log/run
set -eu
SERVICE_NAME=`basename $(dirname $(dirname $(readlink -f $0)))`
LOG_DIR=/var/log/runit/${SERVICE_NAME}
USER=root
GROUP=root
# Create log dir and fix owner & mode
mkdir -p ${LOG_DIR}
chown ${USER}:${GROUP} ${LOG_DIR}
chmod 700 ${LOG_DIR}
exec /usr/bin/chpst -u ${USER} /usr/bin/svlogd -tt ${LOG_DIR}Using sv-utils:
#!/usr/bin/env svrun
service('daemon').call#!/usr/bin/env svrun
loggerd.callMoreover, options as :user and :group are supported
by loggerd and service methods, as:
service('daemon', user: :john_doe).call:command, defined in config for loggerd, is used by default,
but it can be overriden (for example using socklog):
#!/usr/bin/env svrun
loggerd(['svlogd', '-t', 'main/*'], user: :log).callLog directory is created, under the hood, during loggerd call.
sv-utils is an attempt to bring DRY principle
to runit services creation.