:: Re: [DNG] Updated personal runit we…
Top Page
Delete this message
Reply to this message
Author: Ludovic Bellière
Date:  
To: dng
Subject: Re: [DNG] Updated personal runit web page
Hello,

A bit of feedback after setting up my local runit based on the howto.

First thing is the usage of directories and their names. I settled on:

       mkdir -p "${HOME}/runit.s/"{active,disabled,bin}


The `bin' directory is there to host the various helper scripts needed to run
runit itself, such as `svl' and `runsvdir_user'.

The `disabled' directory is there to host the daemon files that are not yet
active.

The `active' directory is the reverse: contains symlinks to the stuff present in
the `disabled' directory.

- - -

For each service:
   * a conf file (sh format), contains variable for both the service/run file and
     the service/log/run file.
   * a log sub-directory containing a `run' file.


Example content of the log/run file:

--8<---------------cut here---------------start------------->8---
#!/bin/sh

[ -r ../conf ] && . ../conf

if [ "${LOGGING_ENABLE}x" = "1x" ]; then
     # Create the log directory if not exists.
     [ -d "${LOG_DIR:-}" ] || mkdir -p "${LOG_DIR:-}"


     exec svlogd -tt "${LOG_DIR:-}"
else
     exec chpst -b mpd-log-null cat >/dev/null
fi
--8<---------------cut here---------------end--------------->8---


This snipped has for effect to enable logging if the service is configured for
it. Otherwise, it logs to null. Thus, for logging purposes, I created a
`/var/log/user.s/@USERNAME@/' directory with the user's ownership, and directed
runit to log there through `LOG_DIR'. Don't ask me what happens if LOG_DIR isn't
set, I don't know.

On the website, it is specified to exec runsvdir with dots appended to the
command[1]. That didn't work for me: runit complained with: "log must have at least
seven character."[2]. Removing the 'Log: ...' part solved my issue.

- - -

runit doesn't support dependencies. However you can delay the start of a daemon
by checking the status of whatever it needs. Returning with an error will tell
runit to wait before retrying, until timeout. For example, using pipewire-pulse
that requires pipewire, the pipewire-pulse daemon will exit with 1 until
pipewire is available:

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env sh

svl check pipewire > /dev/null || exit 1

[ -r ./conf ] && . ./conf

exec chpst -U user:pipewire pipewire-pulse ${OPTS:-} 2>&1
--8<---------------cut here---------------end--------------->8---

The annoyance is that the service will fail to start without saying why.

- - -

On the examples given on the bottom of the page, fetchmail only doesn't require
a supervisor. It exists as a mature daemon capable of handling itself
painlessly. You can run it as a daemon and send a `kill -s SIGUSR1' to it in
order to force a poll. If you still want to have runit supervise it, then use
the `--nodetach' flag in addition to `--daemon <interval>'. No dirty infinite
loop required. But really, fetchmail manages its own pid file and will refuse to
start if it somehow still exists. Which may be helpful when it doesn't stop
cleanly.

- - -

That's about all I could think off. I hope whatever I wrote can be of help.

Cheers,
                 Ludovic


[1]: https://www.troubleshooters.com/linux/init/normal_user_runit.htm#makerunsvdirrunner
[2]: https://github.com/g-pape/runit/blob/main/src/runsvdir.c#L141

On Fri, 12 Sep 2025, Steve Litt wrote:

>Hi all,
>
>On the #void-offtopic IRC channel I got a lot of feedback in my
>personal runit web page at:
>
>https://troubleshooters.com/linux/init/normal_user_runit.htm
>
>Most of the feedback asked for more realistic and sophisticated
>daemons. You can see what I've done, in that regard, so far, at:
>
>https://troubleshooters.com/linux/init/normal_user_runit.htm#mymoves
>
>There are some other changes throughout the file, but the preceding URL
>showcases the most important changes.
>
>All you feedback people: THANKS! You have no idea how much I learned
>moving these other daemons to my personal runit.
>
>SteveT
>
>Steve Litt
>http://444domains.com
>