From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5927 invoked from network); 31 Jan 2021 07:49:57 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 31 Jan 2021 07:49:57 -0000 Received: (qmail 26481 invoked by uid 89); 31 Jan 2021 07:50:17 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 26467 invoked from network); 31 Jan 2021 07:50:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1612079384; bh=CYP8dWbXk4CQx71B+OeyXobc0ABNm7Up57+OZw0WTk8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=e3/eD/Lk0nDYLbLB8LYKbzR+Ke5lIalSziWmUhVsTG3QHNTQ3dMHx7Vs5fvWySwUt K3R8Xg4B1GIUByAeRj7WEpzwMgZxNMbVESJL6BOyTdBWyTfeGhMVJGKSvBeYhZrLSJ Tzlp/Td6Y4f3EoKHdemIpFgSqQfICQaOCRSE4btU= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 MIME-Version: 1.0 Message-ID: From: s.karrmann@web.de To: supervision@list.skarnet.org Cc: ska-supervision@skarnet.org Subject: stage2 as a service [was: Some suggestions on old-fashioned usage with s6 2.10.x] Content-Type: text/plain; charset=UTF-8 Date: Sun, 31 Jan 2021 08:49:44 +0100 Importance: normal Sensitivity: Normal In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:wrs8mxzRBSS6xSRNKd2iFIbdU9qvI4TE0fg09myKDjm1j1h1iZYuwqLPw+2jRJVLOFIWT V2/1ihfEi2poYH+QHkhuhPpXl9ga9TSHwpuAdmXpL7LokQ8n2olW9bOypFvn6i5M8v9ZWC/GguEy TZEBwTI3PjwYi8O/BxCg7ZfFJD7VbcYPRwQQ/Rf2fzs5zX8o9QOvqP1/ckMMrMVEZ/3aOY8O19KB iT/ShWGGj4emm8o5YkDPfGOZYBezl5RHoZf0xtfmahjvpykRwxererdS1xKA7vlg3zhwPFRga4zv oo= X-UI-Out-Filterresults: notjunk:1;V03:K0:gNVQtBQWL0c=:BDBiE8fXdxg86pCF2jrcGy H9rQpGlwYp8mNJBJnSEFcGm7YSlnt7V1CHEz3fJWzwx2AT0pDqML8RoCIKpLzrjabN2RmrwEa 5OHL+ZXLYisMSZKa1u330byF6a82RhdsdH+swEkvunMt9aeDc+DO0uVRssmYqjuVQa8nboV0G VlatIxy6F5WeKuTOcoqYdQh45ixgOwhfkxUdYcCw5ZydiMpblCrelsBjUScOmtxA0EPbg2jcs tE/S/zbK0z6DmcRFbsJysBwdAY8HOAVDql8ckWjNgZI/lgiunzDX4CdLy6vR69hGFiNC3Xn7p js1yR2LDbPv2Wy7Xtx8TSzVoM3CHFjD0p83zUwEFcBojtnd8H/O5y8PWMqDDUOHklPL1YmWbQ QOb6BietwiEsKa8YaCDcZFrbH9UCWdU5xoZZz1fR8Bh6FiKrvZu2z/WTVNoksdkLLZwnrckEh q9L6CC7YvCQ6+pWhpUsWudraBfnpXDm5Mrhx2DFDfHscngP+BtzdfeRtBRDxy2RnT2te2xwM9 ANmgbbAZRE9FDUqOfqw5QSuI+k6lf5HXkJpTjKHFQJafU+dvIneP1RvoWfSl+iZ+CsSxhByl+ gllk4tdvy7sp4= 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=2E16:48 > From: "Laurent Bercot" > To: "Casper Ti=2E Vector" , supervision@list= =2Eskarnet=2Eorg > Subject: Re: Some suggestions on old-fashioned usage with s6 2=2E10=2Ex >=20 > [=2E=2E=2E] > >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=2E search for "careful handling" in [1])=2E >=20 > I feel like you misinterpreted my meaning=2E > 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=2E > [=2E=2E=2E]=C2=A0 $ cat /etc/s6/services/s6-rc-up/run=20 #! /usr/bin/execlineb -P s6-envdir /etc/s6/init-env multisubstitute { importas SCANDIR SCANDIR importas LIVEDIR LIVEDIR =20 importas COMPILED COMPILED =20 importas RCDEFAULT RCDEFAULT =20 importas PATH PATH =20 } 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 =2E } # 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=2E" } fdclose 1 # -- Question: Is this necessary? # NB: shutdown should create =2E/down here, to avoid race conditions # NB: init must ensure that there is no =2E/down here at startup=2E # That is automatically fulfilled, if copied from a repo to /run/=2E=2E=2E ### THE END ##############################################################= ####### and my init is: $ cat /etc/s6/init #! /usr/bin/execlineb -P =20 cd / s6-setsid -qb =20 envfile /etc/s6/init-envfile = =20 multisubstitute { importas SCANDIR SCANDIR importas LIVEDIR LIVEDIR =20 importas COMPILED COMPILED =20 importas RCDEFAULT RCDEFAULT =20 importas PATH PATH =20 } export PATH ${PATH} =20 =20 # stage 1 init as PID=3D1 =20 ifelse -nX =20 { # basic initialization foreground { # a hooks elglob -s locals /etc/s6/init=2Ed/stage1a=2Ed/* forx -E local { ${locals} } ${local} } foreground { # cf=2E https://code=2Edogmap=2Eorg=2E/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=2Ed/stage1b=2Ed/* 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=2Ee=2E 10 minutes=2E # kernel panic } # now the /dev must contain some files, i=2Ee=2E /dev/null redirfd -r 0 /dev/null # useful for testing from a tty, i=2Ee=2E don't co= nsume input execline-cd ${SCAN} # catch all log also for stage 2 # s6-log duplicates it to console redirfd -wnb 1 =2E/s6-svscan-log/fifo # open fifo nonblocking fdmove -c 2 1 # copy it emptyenv -P exec -c s6-svscan # start service scanner, i=2Ee=2E PID=3D= 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=2E Well, it will be=2E I'm still moving my = Debian from systemd ("black box") to s6=2E=2E=2E Also I may switch to s6-linux-init finally=2E Kind regards, Stefan