Re: capturing system shutdown signals?
Alexander Schreiber <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.general |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Apr 27, 2024 at 02:22:57AM +0300, Stas Boukarev wrote:
> systemd is able to execute commands in ExecStop=.
You are mixing different things. ExecStop in systemd is part of the
systemd control flow for units and has nothing to do with signal
handling or system/kernel level handling of process termination.
_If_ your service runs as a systemd unit you _might_ be able to use
this to run a command to signal your process "hey, could you shutdown
gracefully before I shoot you in the head, please?". E.g. for a
webserver you could call a /quitquitquit URL endpoint (which you'd then
have to ACL to e.g. localhost to keep others from having fun at your
expense). That endpoint, once invoked, should then perform whatever
is needed to gracefully shutdown your webserver (e.g. refuse further
incoming connections, wait for running URL handlers to complete (with
timeout), close open files, ... and finally exit).
Kind regards,
Alex.
--
"Opportunity is missed by most people because it is dressed in overalls and
looks like work."