Re: Possible to shut down an s6 service via command rather than signal?

From: Dewayne Geraghty <dewayne_at_heuristicsystems.com.au>
Date: Thu, 25 Jul 2024 11:15:41 +1000

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.
Received on Thu Jul 25 2024 - 03:15:41 CEST

This archive was generated by hypermail 2.4.0 : Thu Jul 25 2024 - 03:17:15 CEST