supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Dewayne Geraghty <dewayne@heuristicsystems.com.au>
To: Brett Neumeier <random@freesa.org>
Cc: supervision@list.skarnet.org
Subject: Re: Possible to shut down an s6 service via command rather than signal?
Date: Thu, 25 Jul 2024 11:15:41 +1000	[thread overview]
Message-ID: <4664aee1-4ae5-4abb-b02a-3520b259655d@heuristicsystems.com.au> (raw)
In-Reply-To: <20240724123027.8c04a742f5ee892725c2120f@freesa.org>

Brett, I had a similar issue.  (Please note: I do not use qemu and only 
use FreeBSD/HardenedBSD, with lots of lightweight jails).

I'm surprised you need to write a catcher for signals as that should be 
caught by your init (Id:1) process which should be graceful?

I replaced init with s6-svscan, so here's what I've done, for 
shutdown.sh (and lots of other maintenance things)
s6-rc -v 9 -da -t 10000 change > /dev/console
s6-rc -v 9 -Da -t 20000 change > /dev/console
sync 2>&1 > /dev/console

For .s6-svscan i have scripts to capture signals for:
SIGINT SIGTERM SIGUSR1 SIGUSR2 finish crash
Each does similar things except finish, which perform
sync
umounts
lots of other things (graceful jail shutdown, transmit closed log files) 
and initiates a halt or reboot depending on the signal.

An example of signal capture: .s6-svscan/SIGUSR2
#!/usr/local/bin/execlineb -S0
fdmove -c 2 1
redirfd -wnb 1 /dev/console
foreground { echo Executing SIGUSR2 }
exec /s/scan/.s6-svscan/finish USR2

You should be able to do everything in the context of s6 :)
Good luck.


  parent reply	other threads:[~2024-07-25  1:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24 17:30 Brett Neumeier via supervision
2024-07-24 18:15 ` Carlos Eduardo
2024-07-24 21:09   ` Laurent Bercot
2024-07-25  1:15 ` Dewayne Geraghty [this message]
2024-07-25 16:26   ` Brett Neumeier via supervision
2024-07-25 16:56     ` Mario Rugiero
2024-07-29 17:29     ` Jan Braun
2024-07-30 19:33       ` Brett Neumeier via supervision

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=4664aee1-4ae5-4abb-b02a-3520b259655d@heuristicsystems.com.au \
    --to=dewayne@heuristicsystems.com.au \
    --cc=random@freesa.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).