How I’d like my init system / service supervisor to be
October 1, 2025 on Runxi Yu’s Website

Here are just some thoughts for comment; no implementation exists yet, and I might decide to contribute to an existing init or write my own (made a stub repo) if things don’t work out in existing projects, sometime™.

“System state is a computed function of the dependency graph rather than as a mutable imperative set of unit states.”

Concepts

TODOs

Examples

I forgot how the services below start or present readiness… these are just conceptual examples.

Let’s say you run Maddy, an email server that provides IMAP and SMTP in one binary. It uses sd_notify and depends on the network being online — but we don’t want to terminate it when we go offline. Note that exec-stop is typically unnecessary as we send SIGTERM by default; we just list it here to note that you could change it.

unit:        maddy
type:        foreground-notified
provides:    imapd, smtpd
depends-ms:  network-online
exec-start:  /usr/bin/maddy run
exec-reload: /bin/kill -USR1 $MAINPID
exec-stop:   /bin/kill -TERM $MAINPID

network-online is a virtual unit that is satisfied if and only if your DHCP client, network interfaces, local resolver, etc., are ready.

unit:        network-online
type:        virtual
provides:    network-online
depends-on:  netif, dhcp, dns

Of course, these dependencies also need to be defined:

unit:        dhcpcd
provides:    dhcp
depends-on:  netif
...
unit:        netif
provides:    netif
type:        oneshot
exec-start:  /etc/my-script-to-set-up-interfaces-with-iproute2
...
unit:        unbound
provides:    dns
depends-on:  netif
...

Let’s run an IRC daemon.

unit:        inspircd
provides:    ircd
depends-ms:  network-online
...

We also have an IRC bot that connects to multiple networks. We want to wait for our own network to be up before it begins, but if our own network fails then just connect to other networks anyway.

name:        irc-bot
type:        foreground-notified
provides:    irc-bot
depends-ms:  network-online
waits-for:   ircd
ready-grep:  ^connected to
exec-start:  /usr/local/bin/irc-bot -c /etc/irc-bot.conf
exec-reload: /bin/kill -USR1 $MAINPID