supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* Have s6-svscan send SIGTERM to one logger
@ 2024-12-02 17:35 Paul Sopka
  2024-12-02 19:37 ` Laurent Bercot
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Sopka @ 2024-12-02 17:35 UTC (permalink / raw)
  To: supervision


[-- Attachment #1.1.1: Type: text/plain, Size: 908 bytes --]

Hey everybody

I have a logger supervised by the very s6-svscan instance it logs 
through the fifo trick.
Now sending SIGTERM to the s6-svscan process won't work, since it waits 
for the logger forever,
which in turn waits for s6-svscan to close the fifo.
I have solved this by the following script:

.s6-svscan/SIGTERM

| #!/bin/execlineb -P
|
| # in case no message has been sent yet
| foreground { echo }
|
| foreground { s6-svc -h s6-svscan-log }
|
| s6-svscanctl -t .

This has the obvious downside that the catch all logger is brought down 
early.
Since this is not the main supervision tree, I require the ability to 
stop this instance of s6-svscan.
This also means that it is not too bad that the catch all logger is 
brought down early,
since logs are propagated up the hierarchy.

Still, I wonder whether there is a more elegant solution to this.

Regards

Paul


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3195 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Have s6-svscan send SIGTERM to one logger
  2024-12-02 17:35 Have s6-svscan send SIGTERM to one logger Paul Sopka
@ 2024-12-02 19:37 ` Laurent Bercot
  2024-12-02 21:05   ` Paul Sopka
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Bercot @ 2024-12-02 19:37 UTC (permalink / raw)
  To: Paul Sopka, supervision

>I have a logger supervised by the very s6-svscan instance it logs through the fifo trick.
>Now sending SIGTERM to the s6-svscan process won't work, since it waits for the logger forever,
>which in turn waits for s6-svscan to close the fifo.

  There is no good solution to this. s6-svscan, the catch-all logger's
s6-supervise, and the catch-all logger, are codependent. This is why
the construct should only be done once, for the root supervision tree,
and the catch-all logger never needs to be killed. (It logs to a RAM
filesystem so its existence does not prevent any unmounting.)


>Since this is not the main supervision tree, I require the ability to stop this instance of s6-svscan.

  If this is not the main supervision tree, there is no reason for you
to use the fifo trick and have the s6-svscan log to something under
itself.
  Start the inner s6-svscan as a regular service, with a logger that is
supervised by the *outer* supervision tree.

--
  Laurent


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Have s6-svscan send SIGTERM to one logger
  2024-12-02 19:37 ` Laurent Bercot
@ 2024-12-02 21:05   ` Paul Sopka
  2024-12-03  0:56     ` Re[2]: " Laurent Bercot
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Sopka @ 2024-12-02 21:05 UTC (permalink / raw)
  To: supervision, Laurent Bercot


[-- Attachment #1.1.1: Type: text/plain, Size: 963 bytes --]

>  If this is not the main supervision tree, there is no reason for you
> to use the fifo trick and have the s6-svscan log to something under
> itself.
>  Start the inner s6-svscan as a regular service, with a logger that is
> supervised by the *outer* supervision tree. 
This is what I did before, but in an effort to make the 
"sub-supervision-tree"
independent of whatever init-system/service manager is used for the main 
tree,
I tried what I described.

Since there is no elegant solution to this,
I will resort to do as you suggest.

A second application for this fifo trick is to have a supervision tree
launched as the child of a graphical session, e.g. a wayland compositor,
to start things like a notification daemon or wallpaper software,
requiring the wayland compositor (and e.g. ${WAYLAND_DISPLAY}) to be set up.
For this application, ist what I proposed the "least bad solution"?

Thank you and have a nice evening

Paul


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3195 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re[2]: Have s6-svscan send SIGTERM to one logger
  2024-12-02 21:05   ` Paul Sopka
@ 2024-12-03  0:56     ` Laurent Bercot
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Bercot @ 2024-12-03  0:56 UTC (permalink / raw)
  To: Paul Sopka, supervision

>This is what I did before, but in an effort to make the "sub-supervision-tree"
>independent of whatever init-system/service manager is used for the main tree,
>I tried what I described.

  Well, it's not very satisfying, but I understand the wish, so here
is how I do it on Alpine Linux. You can take inspiration from it:

https://gitlab.alpinelinux.org/alpine/aports/-/raw/master/main/s6/s6-svscanboot

  This is invoked by openrc in order to start a new supervision tree.
OpenRC doesn't provide any native logging infrastructure, so the
script creates its own catch-all logger. The fd dance is similar to
what s6-linux-init does. Killing s6-svscan *should* also make the
catch-all logger die on its own. (It was buggy in previous versions,
but with the current version of s6, it should work).

  Note that /dev/console is explicitly mentioned towards the end,
because openrc doesn't provide an open fd to it to its services. If
you want your script to be portable to any service manager, you should
probably do the same. Else, you could try saving the script's stderr
instead, and making it s6-svscan's console holder, but that requires
a little more fd dancing, and that won't work with OpenRC or other
service managers that don't give you a suitable stderr fallthrough.

--
  Laurent


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-03  0:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-02 17:35 Have s6-svscan send SIGTERM to one logger Paul Sopka
2024-12-02 19:37 ` Laurent Bercot
2024-12-02 21:05   ` Paul Sopka
2024-12-03  0:56     ` Re[2]: " Laurent Bercot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).