supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Jan-willem De Bleser <jw@thescrapyard.org>
To: supervision@list.skarnet.org
Subject: Re: s6-svscan shutdown notification
Date: Wed, 23 Feb 2022 21:16:04 -0800	[thread overview]
Message-ID: <CAHgrPWKeNYMoZsoV3x9D9gy+M2e_NhQGeikL=hQQJCV2deyEUg@mail.gmail.com> (raw)
In-Reply-To: <em1ae27b6d-f148-4597-a1ed-ffd574532e37@elzian>

[-- Attachment #1: Type: text/plain, Size: 1722 bytes --]

Not an option to be its parent since there's no persistent supervisor of a
jail's root process, but that script using .s6-svscan/finish should do
nicely. Thanks for the suggestion!

- Jw


On Wed, Feb 23, 2022 at 9:04 PM Laurent Bercot <ska-supervision@skarnet.org>
wrote:

>
> >What's the cleanest way to wait on s6-svscan to shut down after issuing of
> >a SIGTERM (say s6 via-svscanctl -t)?
>
>   Be its parent, and wait for it. :)
>   On SIGTERM, s6-svscan will not exit until the supervision tree is
> entirely down, so that will work.
>   If you're not the parent, then you'll have to wait for a notification
> somehow, but that's easy:
>
>   When s6-svscan wants to exit, it doesn't exit right away, but
> tries to exec into the .s6-svscan/finish script. So you have a clear
> indicator here: when .s6-svscan/finish runs, it means the supervision
> tree is down.
>   So, for instance, make a finish script that writes a byte in a fifo,
> and have your jail shutdown script read on that fifo. Something like:
>
> .s6-svscan/finish:
> #!/bin/sh
> exec echo > /run/blah/fifo
>
> shutdown script:
> #!/bin/sh
> ...
> rm -f /run/blah/fifo
> mkfifo /run/blah/fifo
> read < /run/blah/fifo &
> s6-svscanctl -t /run/service
> wait
> ...
>
> (read on the fifo before running s6-svscanctl, to avoid the small
> race condition.)
>
>
> >Looking at the documentation, my only option appears to be to check if the
> >return code of s6-svscanctl is 100, or maybe to monitor for the existence
> >of .s6-svscan/control (not sure if it's removed on exit). Are there any
> >other ways to monitor s6-svscan?
>
>   Ew. Don't poll.
>   Use .s6-svscan/finish to do anything you want to do at s6-svscan
> death time.
>
> --
>   Laurent
>
>

  reply	other threads:[~2022-02-24  5:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24  1:27 Jan-willem De Bleser
2022-02-24  5:04 ` Laurent Bercot
2022-02-24  5:16   ` Jan-willem De Bleser [this message]
2022-02-25 16:52     ` Jan Bramkamp
2022-02-26 16:12       ` Jan-willem De Bleser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHgrPWKeNYMoZsoV3x9D9gy+M2e_NhQGeikL=hQQJCV2deyEUg@mail.gmail.com' \
    --to=jw@thescrapyard.org \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).