runit icon indicating copy to clipboard operation
runit copied to clipboard

Handle SIGPWR signal (shutdown)

Open Anachron opened this issue 5 years ago • 7 comments

LXC/LXD sends sigpwr signal to Pid 1 but it doesn‘t listen to it, thus stopping LXC/LXD from stopping the container correctly.

Anachron avatar Mar 23 '19 06:03 Anachron

There is already a patch for runit to react on SIGPWR here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923924

Anachron avatar Mar 23 '19 14:03 Anachron

I believe this is the wrong repository for the issue, open one in https://github.com/void-linux/void-packages/ or directly file a PR there.

faulesocke avatar Jun 13 '19 09:06 faulesocke

This should be moved to https://github.com/void-linux/runit . @ericonr

CameronNemo avatar Aug 16 '20 18:08 CameronNemo

For the pretty patch from Debian, see here

ericonr avatar Aug 26 '20 23:08 ericonr

Regarding the debian patch, here is my comment from another issue:

I'm not completely happy with it, I would like to have a mechanism to completely disable sigpwr for non containers and users who may run a UPS that sends sigpwr but don't want this to shutdown the system or handle in some other way.

This also requires man page updates, we shouldn't just change how init behaves when it is signaled without documenting it and considering edge cases.

I would add /etc/runit/sigpwr which is checked for for existence and executable bit. Create it from our core services, and chmod u+x it if it is a "container" system.

This would not change anything for normal users, introduce the wanted behavior for "containers" and allows users with USPs that send a signal to pid 1 to enable it by chmod u+x the file.

https://github.com/void-linux/void-packages/pull/20098#issuecomment-601189877

Duncaen avatar Sep 11 '20 11:09 Duncaen

A working Hotfix (if you're not relying on SIGCONT being sent to init) (for example, for embedding into the lxc template hook):

Set the executable flag on /etc/runit/stopit and add lxc.signal.halt = SIGCONT to the lxc configuration file: setting the executable flag causes runit to shutdown on SIGCONT, and the configuration addition causes LXC to send SIGCONT signals instead of SIGPWR on non-forced shutdown requests (like the ones by lxc-stop).

Because /etc/runit/stopit is just a symlink to /run/runit/stopit (which in turn is not persistent over reboots), you have set the +x flag on every reboot. This could be done easily by something like appending chmod +x /run/runit/stopit to /etc/rc.local.

I have no idea what this might break though.

ghost avatar Jan 25 '21 14:01 ghost

The upstream LXC/LXD Void image now modifies /etc/runit/1 to set the mode for /run/runit/stopit to 100. Unfortunately this won't survive an update to the runit-void package, so using /etc/rc.local to change the mode is still needed.

In a similar way to LXC, LXD users will also need to change the signal with lxc config set <instance> raw.lxc lxc.signal.halt=SIGCONT.

amak79 avatar Oct 05 '21 02:10 amak79