[systemd-devel] How can you differentiate behavior between stop and stop as part of restart?
Michal Koutný
mkoutny at suse.com
Thu Nov 7 19:43:52 UTC 2024
Hello.
On Mon, Oct 14, 2024 at 05:54:28PM GMT, 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.
Congrats!
> 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.
It can't be repeated enough, so adding mine: please don't use
KillMode=none (it bypasses invariants systemd'd like to have and it's
not safe in general).
> I see some long past discussion about adding supporting for ExecRestart
> which could theoretically solve the problem but I figure I'm stuck thinking
> about it the wrong way.
Yeah, it dind't take off :-/
> What's the systemd canonical way to set get the desired behavior?
Possibly you could achieve similar behavior with ExecReload= (that could
even be considered canonical if you redefine what you mean by graceful
restart).
(If this was only about distinguishing plain vs restart stop operation,
you could configure different RestartKillSignal= and KillSignal=
however, old generation processes should still be cleaned up before
starting the new one.)
Michal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20241107/410e92db/attachment.sig>
More information about the systemd-devel
mailing list