Dear all, after Laurents explanation about the supervision tree in stage 2 and 3, I got the idea to put stage2 completely into a normal supervised service:
> 2021-01-29.16:48 > From: "Laurent Bercot" <ska-supervis...@skarnet.org> > To: "Casper Ti. Vector" <caspervec...@gmail.com>, supervision@list.skarnet.org > Subject: Re: Some suggestions on old-fashioned usage with s6 2.10.x > > [...] > >There is some non-trivial trade-off: in short, the existence of the > >supervision tree after stage 2 is by itself a kind of "special case" > >(eg. search for "careful handling" in [1]). > > I feel like you misinterpreted my meaning. > The *absence* of a supervision tree after stage 2 is precisely what > requires careful handling, and runit only works because Linux has > that peculiarity that kill -9 -1 does not kill the emitter! > Having a supervision tree in stage 3 actually *helps* with the > late shutdown procedure: shutdownd dies right after the kill (which > would make it usable even on a system without the Linux specialcase) > and is restarted by the supervisor for stage 4. > [...] $ cat /etc/s6/services/s6-rc-up/run #! /usr/bin/execlineb -P s6-envdir /etc/s6/init-env multisubstitute { importas SCANDIR SCANDIR importas LIVEDIR LIVEDIR importas COMPILED COMPILED importas RCDEFAULT RCDEFAULT importas PATH PATH } export PATH ${PATH} # optional: -- Question: Is this necessary? redirfd -w 0 ${SCANDIR}/service/s6-svscan-log/fifo # now the catch all logger runs fdclose 0 foreground { mkdir -p ${LIVEDIR} } foreground { s6-rc-init -l ${LIVEDIR}/live -c ${COMPILED} ${SCAN} } foreground { s6-svc -O . } # don't restart me foreground { s6-rc -l ${LIVEDIR}/live -t 10000 change ${RCDEFAULT} } # notify s6-supervise: fdmove 1 3 foreground { echo "s6-rc ready, stage 2 is up." } fdclose 1 # -- Question: Is this necessary? # NB: shutdown should create ./down here, to avoid race conditions # NB: init must ensure that there is no ./down here at startup. # That is automatically fulfilled, if copied from a repo to /run/... ### THE END ##################################################################### and my init is: $ cat /etc/s6/init #! /usr/bin/execlineb -P cd / s6-setsid -qb envfile /etc/s6/init-envfile multisubstitute { importas SCANDIR SCANDIR importas LIVEDIR LIVEDIR importas COMPILED COMPILED importas RCDEFAULT RCDEFAULT importas PATH PATH } export PATH ${PATH} # stage 1 init as PID=1 ifelse -nX { # basic initialization foreground { # a hooks elglob -s locals /etc/s6/init.d/stage1a.d/* forx -E local { ${locals} } ${local} } foreground { # cf. https://code.dogmap.org./fs/ elglob fss /fs/* forx -E -p fs { ${fss} } if { test -e ${fs}/mount-at-boot } mount ${fs}/mount # todo fsmount ${fs} } foreground { # b hooks elglob -s locals /etc/s6/init.d/stage1b.d/* forx -E local { ${locals} } ${local} } foreground { ln -s /fs/run-s6/mount/${SCANDIR} /run/s6 } foreground { mkdir -p /fs/run-s6/mount/${SCANDIR} } cp -a ${REPO} ${SCANDIR} } { # fallback login sulogin --force -t 600 # timeout 600 seconds, i.e. 10 minutes. # kernel panic } # now the /dev must contain some files, i.e. /dev/null redirfd -r 0 /dev/null # useful for testing from a tty, i.e. don't consume input execline-cd ${SCAN} # catch all log also for stage 2 # s6-log duplicates it to console redirfd -wnb 1 ./s6-svscan-log/fifo # open fifo nonblocking fdmove -c 2 1 # copy it emptyenv -P exec -c s6-svscan # start service scanner, i.e. PID=1 in stage 2 ### THE END ##################################################################### I have three basic services: - s6-linux-init-early-getty - s6-rc-up - s6-svscan-log Everything else is up to s6-rc. Well, it will be. I'm still moving my Debian from systemd ("black box") to s6... Also I may switch to s6-linux-init finally. Kind regards, Stefan