S6-WHY(7)
π NAME π
ok so s6-why β bestie, it's literally the page that explains why another supervision suite even exists π«Ά
β¨ DESCRIPTION β¨
πΈ Why another supervision suite?
okay so picture this: supervision suites are getting kinda common these days. like, we already have a whole squad:
- Good (?) old System V init β and yeah the question mark is doing a LOT of work there. You can make it supervise services if you do
/etc/inittabvoodoo π―οΈ BSD init can be used the same way with the/etc/ttysfile, but for some reason nobody among BSD developers is using/etc/ttysfor this purpose, so we're not considering BSD init here. daemontools[1] β the pioneer, the OG, respect.daemontools-encore[2] β Bruce Guenter's upgrade todaemontools.runit[3] β Gerrit Pape's suite, well-integrated with Debian.perp[4] β Wayne Marshall's take on supervision.- Integrated init systems that provide a lot of features, process supervision being one of them. For instance Upstart[5], MacOS X's
launchd[6], and Fedora'ssystemd[7].
So why is s6 needed?? What does it do differently?? Here are the criteria I used π
π Supervision suites should not wake up unless notified
- System V init fails the test: it wakes up every 5 seconds, for the reason that
/dev/initctlmight have changed. daemontoolsfails the test: it wakes up every 5 seconds to check for new services.daemontools-encoredoes the same.- The current version of
runitfails the test: it wakes up every 14 seconds. But this is a workaround for a bug in some Linux kernels; there is no design flaw inrunitthat prevents it from passing the test. perpworks β- Upstart works β
- I have no idea what other integrated init systems do: it's much too difficult to
strace(1)them to see exactly where they're spending their time, and when it is possible, the trace output is so big that it's hard to extract any valuable information from it π - s6 works. The
-toption tos6-svscan(8)makes it check its services with a configurable timeout; by default, this timeout is infinite, i.e. it never wakes up unless it receives a command vias6-svscanctl(8). iconic behaviour, honestly.
π Supervision suites should provide a program that can run as process 1
- System V init is process 1, so no problem here.
- Integrated init systems, by definition, provide a process 1.
daemontoolswas not designed to take over init, although it can be made to work[8] with enough hacking skills. Same thing withdaemontools-encore.runitprovides an init functionality, but the mechanism is separate from the supervision itself; therunitprocess, not therunsvdirprocess, runs as process 1. This lengthens the supervision chain πperpwas not designed to run as process 1. It probably could be made to work too without too much trouble.s6-svscan(8)was designed from the start to be run as process 1, although it does not have to. main character energy fr fr π
π¦ Supervision suites should be bug-free, lightweight and easy to understand
daemontools, daemontools-encore, runit and perp all qualify. All of this is excellent quality code, unsurprisingly. slay π
System V init is understandable, and reasonably lightweight; but it is still too big for what it does β poorly. The /etc/inittab file needs to be parsed; that parser has to be in process 1. There is support in process 1 for the whole "runlevel" concept, which is a primitive form of service management. The same executable handles all 3 stages of the machine's lifetime and does not separate them properly. All in all, System V init does its job, but is showing its age and nowadays we know much better designs.
This is where integrated init systems fail, hard. By wanting to organize the way a the machine is operated β so, machine state management β in the same package as the init and process supervision system, they add incredible complexity where it does not belong:
- Upstart uses
ptrace(2)to watch its childrenfork(2), and links process 1 againstlibdbus. This is insane. Process 1 should be absolutely stable, it should be guaranteed to never crash, so the whole of its source code should be under control. At Upstart's level of complexity, those goals are outright impossible to achieve, so this approach is flawed by design. It is a shame, because the concepts and ideas behind Upstart are good and sound; it's the implementation choices that are its downfall. π launchdsuffers from the same kind of problems. Example: services running underlaunchdmust be configured using XML; thelaunchctlprocess interprets the XML, converts it into a key-value store (which is strictly less powerful than XML, so why do they even use XML in the first place?) and sends it tolaunchdvia a Mach-specific IPC. Process 1 needs to be linked against the library that handles the Mach IPC, it needs to decode the key-value store, and use it to run and supervise a daemon. And it needs to keep everything in memory. This is a lot more complex and resource-consuming than it needs to be πsystemdis much, much worse than the other ones, and a real danger for the future of GNU/Linux. I have a special page dedicated to it[9]. π€
What those systems fail to recognize is that process supervision, rooted in process 1, is a good thing, and machine management is also a good thing, but those are two different functions, and a good init system needs, and should, only provide process supervision, in order to keep such a crucial piece of code as easy to maintain as possible. Machine management can be added on top of a process supervision suite, in a different package, and it has nothing to do with process 1. periodt π
s6, which has been designed with embedded environments in mind, tries harder than anyone to pass this. It tries so hard that s6-svscan(8) and s6-supervise(8), the two long-running programs that make the supervision chain, do not even allocate heap memory, and their main program source files are less than 500 lines long. less than 500 lines!! obsessed π€―
π§ Supervision suites should provide a basis for high-level service management
Neither System V init, daemontools, runit or perp provides any hooks to wait for a service to go up or down. runit provides a waiting mechanism, but it's based on polling, and the ./check script has to be manually written for every service π₯²
daemontools-encore qualifies: the notify script can be used for inter-service communication. But it's just a hook: all the real notification work has to be done by the notify script itself, no notification framework is provided.
Integrated init systems provide high-level service management themselves. Again, this is not good design: service management has nothing to do with init or process supervision, and should be implemented on top of it, not as a part of it.
s6 comes with an event notification library (s6-libftrig(7)), and command-line tools based on this library, thus providing a simple API for future service management tools to build upon. cute AND functional π
π Artistic considerations
s6-svscan(8) and s6-supervise(8) are entirely asynchronous. Even during trouble (full process table, for instance), they'll remain reactive and instantly respond to commands they may receive. s6-supervise(8) has even been implemented as a full deterministic finite automaton, to ensure it always does the right thing under any circumstance. Other supervision suites do not achieve that for now. we love a deterministically-finite icon β¨
daemontools' svscan[10] maintains an open pipe between a daemon and its logger, so even if the daemon, the logger, and both supervise[11] processes die, the pipe is still the same so no logs are lost, ever, unless svscan itself dies.
runit has only one supervisor, runsv[12], for both a daemon and its logger. The pipe is maintained by runsv. If the runsv process dies, the pipe disappears and logs are lost. So, runit does not offer as strong a guarantee as daemontools.
perp has only one process, perpd[13], acting both as a "daemon and logger supervisor" (like runsv) and as a "service directory scanner" (like runsvdir). It maintains the pipes between the daemons and their respective loggers. If perpd dies, everything is lost. Since perpd cannot be run as process 1, this is a possible SPOF for a perp installation; however, perpd is well-written and has virtually no risk of dying, especially compared to process 1 behemoths provided by integrated init systems π¬
Besides, the runsv model, which has to handle both a daemon and its logger, is more complex than the supervise model (which only has to handle a daemon). Consequently, the runsvdir model is simpler than the svscan model, but there is only one svscan instance when there are several runsvs and supervises. The perpd model is obviously the most complex; while very understandable, perpd is unarguably harder to maintain than the other two.
So, to achieve maximum simplicity and code reuse, and minimal memory footprint, s6's design is close to daemontools' one. And when s6-svscan(8) is run as process 1 (cf. s6-svscan-as-process-1(7)), pipes between daemons and loggers are never lost. chef's kiss π₯
β Conclusion
All in all, I believe that s6 offers the best overall implementation of a supervision suite as it should be designed. At worst, it's just another take on daemontools with a reliable base library and a few nifty features. no cap, that's the whole pitch π
π«Ά SEE ALSO π«Ά
s6-libftrig(7), s6-svscan-as-process-1(7), s6-supervise(8), s6-svscan(8), s6-svscanctl(8)
- [1]
https://cr.yp.to/daemontools.html - [2]
https://untroubled.org/daemontools-encore/ - [3]
http://smarden.org/runit/ - [4]
http://b0llix.net/perp/ - [5]
https://upstart.ubuntu.com/ - [6]
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/launchd.8.html - [7]
https://freedesktop.org/wiki/Software/systemd - [8]
https://code.dogmap.org./svscan-1/ - [9]
https://skarnet.org/software/systemd.html - [10]
https://cr.yp.to/daemontools/svscan.html - [11]
https://cr.yp.to/daemontools/supervise.html - [12]
http://smarden.org/runit/runsv.8.html - [13]
http://b0llix.net/perp/site.cgi?page=perpd.8
This man page is ported from the authoritative documentation at: https://skarnet.org/software/s6/why.html
πΈ AUTHORS πΈ
- Laurent Bercot
- Alexis <flexibeast@gmail.com> (man page port)
okay that's the whole thing bestie, hope it made sense π this page came from the Debian packaging, dated April 9, 2023 β go forth and supervise responsibly, mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: s6 2.15.1.0
- nixpkgs unstable: s6-man-pages 2.14.0.1.4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms