Summary of s6 with s6-rc in Devuan5-init-diversity spin

This is a summary of what I found in the rather longwinded topic

I would welcome any corrections and questions.
It was prepared offline with markdown

Some things I have learnt about s6 init system with s6-rc service manager

This is not a tutorial.
I am a long way from mastering s6-rc, and I have only progressed as far as I
have demonstrated here with generous assistance from @ProwlerGr

S6 on its own is an init system, and a supervisor system for services. That is it starts services when you boot, including the initial s6-svscan process with PID=1 which replaces the traditional ‘init’ process. S6 also supervises all running daemons, in the same manner as runit does, by running supervisor daemons for each service daemon. What supervision does is make sure the daemons stay running, by restarting them if they fail.

On top of S6, one can install a Service Manager. A Service Manager adds a facility for a user to start and stop services ( and a few other things). For example one might wish to temporarily stop the sshd daemon for security reasons.

I have seen 3 different Service Managers used with s6 : s6-rc, s6-66, and OpenRC. They all work. We have been looking at s6-rc in this topic.

s6-rc features

s6-rc is the original Service Manager supplied by Skarnet to work with s6.
I have seen s6-rc in Artix, but its best implementation is probably in the
init-diversity spin releases (Antix, MX, Devuan) which are all Debian based.

There are two concepts in s6-rc that are not prominent in other service managers

  • compiling a database: all service managers have a database, but s6-rc compels the user to manage the database by hand. Other service managers hide the database.
  • bundles: s6-rc has the concept of bundling services together so that they can be managed with a single command. I know of no other init system that has bundles. s6-66 has a related concept called a tree. SysVinit has runlevels which are difficult to configure and are generally unused.

Apart from these two major concepts, s6-rc has all the normal start , stop and status commands for daemons, plus a way of recompiling its database, which must be done after any changes.

s6-rc scripts

Most init systems have run scripts. These are usually shell scripts, but in s6-rc they are execline scripts
What a run script does is start a daemon to provide a service.
S6-rc keeps its ru scripts in /etc/s6-rc/sv. There you will find a directory for each service which has been installed, and inside that directory will be a run script plus other things. For example

$ls /etc/s6-rc/sv/sshd-srv
producer-for	run	type

and the run file contains

$ cat /etc/s6-rc/sv/sshd-srv/run
#!/bin/execlineb -P
##if -t { test -s /etc/ssh/sshd_not_to_be_run } exit 161
foreground { mkdir -p /run/sshd }
foreground { chmod 0755 /run/sshd }
foreground { redirfd -w 1 /dev/null ssh-keygen -A }
foreground { touch /var/log/lastlog }
foreground { chgrp utmp /var/log/lastlog }
foreground { chmod 664 /var/log/lastlog }
envfile /etc/s6-rc/config/openssh.conf
importas -sCuD "" OPTS OPTS
fdmove -c 2 1
exec /usr/sbin/sshd -D -e ${OPTS}

That is an execline script. Execline is like the primitive Unix rc command - it looks at a file and treats each line as a command and runs it. Only execline has some of its own builtin commands, so it is more sophisticaed than rc.
Try to avoid having to write an execline script from scratch. Most of the commonly used services have a run script and other things supplied when their package is installed. If your service does not have a script, try to find or modify one. See my difficulties here

with the vsftpd service.

s6-rc commands

There are only a few important commands

  • s6-rc for managing services

https://skarnet.org/software/s6-rc/s6-rc.html

  • s6-rc-db for managing the database

https://skarnet.org/software/s6-rc/s6-rc-db.html

  • s6-svstat

https://skarnet.org/software/s6/s6-svstat.html

  • the script s6-db-reload which is used to remake the database if you
    change any of the files in `/etc/s6-rc/sv/…

There are no man pages, there is only the skarnet webpages referenced above plus a rather limitred beginners guide

and there are wiki pages from Artix and Gentoo

https://wiki.artixlinux.org/Main/S6

https://wiki.gentoo.org/wiki/S6_and_s6-rc-based_init_system

s6-rc Service Manager GUI

All 3 init-diversity spins come with a GUI service manager for s6-rc ( and there is one for runit and for sysVinit).
The s6-rc GUI can start and stop individual daemons. You have to add each daemon to the GUI bundle ( called antix-service-manager) first. You can use the GUI to do the add operation.
In addition the s6-rc GUI displays the status ( up or down) of each daemon.
The GUI automatically recompiles the database for you. If you use the CLI you have to do it by hand. That is what the script s6-db-reload is for.

the bundles concept in s6-rc

Individual daemons can be grouped together. For example the server daemon and the log daemon for a service an be bundled and managed with one command.
In my testing I managed to bundle vsftpd-srv and vsftpd-log together in to a bundle called vsftpd.
Commands work on bundles, the same way they work on individual services , so I was able to say
s6-rc start vsftpd
and start both daemons at once.
This takes some configuring in /etc/s6-rc/sv and it can not be done with the GUI at present.

s6-rc for a beginner

You will have no trouble with s6 itself. The init system and supervision are not requiring user intervention, they just work ( like in runit).

If you use s6-rc, there will be no difficulties if you stick to services for which the package system provides full s6-rc support.

If you go beyond that , be prepared for a lengthy learning curve. I have been assured that s6-66 is both simpler and superior, compared to s6-rc, so you should probably use s6-66 instead of s6-rc.

3 Likes

I would like to thank you @nevj for the time & effort you spent with these spins, and sharing your unbiased experience in public view.

3 Likes

I have enjoyed working with you @ProwlerGr .
It is not over yet.
We have to put s6-66 to the test. I will shift back to Antix for that… can you stand another round?
The spins helped me get off the ground with s6 … I was floundering on my own with only Artix and Obarun.
and
when it is all over, we need a tutorial so everyone can give s6 a try.

1 Like

You betcha!
I can also suggest the MX spin if you want to see how systemd plays with something else as PID 1.

2 Likes

First question
Is 66 a complete alternative to s6-rc or is it built on top of it?

It used to be a wrapper for s6-rc, but the new version (0.7.0.0) is a full re-write totally independent.

If you have Obarun it still uses the old wrapper version of 66 (until the new Obarun release is out), my antiX/MX/Devuan respins feature the brand new independent version.

That explains why I found Oberon confusing., and why the Oberon docs did not answer my question.

About the only docs available on 66 are Oberon.

I am glad the latest release of 66 is a completely independent
alternative. That makes a study of 66 worthwhile.

2 Likes

A few of the differences between the old 66 (s6-rc wrapper) & new 66 detailed here:
https://web.obarun.org/software/66/latest/66-rosetta.html

2 Likes

I will transfer this discussion of s6-66 to a new topic

3 Likes