sv-user

sv-user toolkit: Supervised user services with runit

Poster

Poster: sv-user toolkit

https://codeberg.org/NaitLee/sv-user

Supervised services? What’s that?

runit is a daemontools-like init. runit process supervisors are runsvdir(8) and runsv(8).

As the poster suggests, they keep service programs (processes) directly as their childs.

The supervisor directly monitors child processes, restarting or stopping them as required/requested with sv(8).

We say such kind of services are supervised.

Hint: use htop(1) and toggle Tree view with F5, with runit-like init, you can see a beautiful process tree.

I once heared about SysV init. Is runit different from it?

SysV init is traditional Unix init. It basically works by:

Demo in shell:

sleep 60 &
echo $! >/tmp/sleep.pid
kill $(cat /tmp/sleep.pid)

In contrast to supervised service management, this doesn’t form a process supervision tree. All service processes are stray “in the background.”

User services? Are they necessary?

Think about that, everytime you want to restart some services, you enter a sudo command and enter your password, to become root.

But the services, when starting, just switch user and become non-root.

Why the hassle to become root, to manage services that are not run as root?

Hint: I recommend to use doas(1) (opendoas) with user services. Examples:

# /etc/doas.conf
permit persist user as root
permit nopass user as server
#!/bin/sh
# /home/user/.config/sv/server/run
exec 2>&1
[ -r ./conf ] && . ./conf
exec doas -u server $HOME/.local/bin/server
ssh myserver
sv-add server
sv-user restart server
exit

systemd and OpenRC also have user service support.

Do you hate systemd?

No.

For real init diversity, saying what’s bad about systemd is not helpful at all.

And we should do more than just listing out various init systems.

Users need freedom and functionality, not only either of them.