[systemd-devel] How can you differentiate behavior between stop and stop as part of restart?

Kelsey Cummings kelsey.cummings at sonic.com
Tue Oct 15 00:54:28 UTC 2024


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.

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.

This behaves as expected and restarts are fast enough for my needs.

HOWEVER, I would like stop to wait for all of the children to gracefully 
exit should stop be called explicitly and/or as part of system 
shutdown/reboot.

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.

What's the systemd canonical way to set get the desired behavior?

-- 
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