Systemd service should default to graceful stop
Originally reported as just a bug in the sysv script of the debian and ubuntu packages of lighttpd (https://bugs.launchpad.net/ubuntu/+source/lighttpd/+bug/1707312), turns out there is no equivalent to a graceful stop/restart in the systemd service file for lighttpd.
This diff was suggested by Vasya Pupkin on that launchpad bug (I refreshed it for the current 1.4 git tree):
--- a/doc/systemd/lighttpd.service +++ b/doc/systemd/lighttpd.service @@ -9,6 +9,9 @@ ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf ExecReload=/bin/kill -USR1 $MAINPID Restart=on-failure +KillMode=mixed +KillSignal=SIGINT +TimeoutStopSec=60
As far as I know, there is no clean way to have a "graceful-restart" systemd action alongside the normal "restart" one, so the above changes behavior a bit in the sense that all actions that involve a "stop" will send the SIGINT signal instead of SIGTERM, unless the timeout is reached, in which case SIGTERM it is.
The argument for KillMode=mixed was made in this comment: https://bugs.launchpad.net/ubuntu/+source/lighttpd/+bug/1707312/comments/26
Updated by stbuehler over 2 years ago
I already pointed you to 0ae6bab4a97f12a0c93200df36ac1741696eeed5 in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=877870#10
Updated by ahasenack over 2 years ago
The USR1 signal may indeed satisfy the requirements of a graceful-restart, so the remaining case is a graceful-shutdown, i.e., wait for existing connections to terminate and not accept new ones. You might decide it's not worth the trouble, given that this systemd service file change affects all stop-related actions, that's fine. I just wanted to bring it up.
Also available in: Atom