[systemd-devel] How can you differentiate behavior between stop and stop as part of restart?
Kelsey Cummings
kelsey.cummings at sonic.com
Thu Oct 17 00:38:53 UTC 2024
On Wed, Oct 16, 2024 at 03:02:58PM +0200, Lennart Poettering wrote:
> On Mo, 14.10.24 17:54, Kelsey Cummings (kelsey.cummings at sonic.com) wrote:
>
> > I've come up to a problem that I haven't been able to figure out how to
> > solve. I have a well behaved daemon process that manages its own children
> > and has both the ability to gracefully reload it's config and gracefully
> > restart. A graceful restart would work best by starting a new parent and
> > then signalling the old parent which would exit once the children complete
> > any in-process requests.
>
> So you have two main processes run in parallel? That's a bit icky...
We have a saying: "Don't yuck my yum". ;)
> > Restart as stop && start is close enough for my use case but in order to
> > ensure the new parent process starts without waiting for the graceful stop
> > to complete I had to set "KillMode=none" and explicitly add the "default"
> > "ExecStop=/bin/kill -s QUIT $MAINPID" to the unit file.
>
> SIGQUIT is supposed to exit and generate a coredump as request from
> the user. It's really weird to use that for anything else. I wouldn't
> call a daemon which uses the signal in a completely different way
> "well behaved" tbh.
No comment on why they chose QUIT for that, but USR1, USR2, WINCH and
HUP all have defined behavior so there's that.
While I'm not strictly trying to accomplish this for nginx, consider the
procedure they describe for upgrading binaries here
https://nginx.org/en/docs/control.html This is more or less what I'm
trying to coax out of systemd without having to use something else to
supervise a random service.
If systemd restart nginx.service was able to send the USR2 signal (or
generically, any custom command) then systemd could be used to support
graceful replacement of any process which is particularly interesting
for network services.
--
kelsey.cummings at sonic.com sonic.net, inc.
System Architect 2260 Apollo Way
707.522.1000 Santa Rosa, CA
More information about the systemd-devel
mailing list