Project

General

Profile

Actions

Feature #2825

closed

Systemd service should default to graceful stop

Added by ahasenack over 6 years ago. Updated over 6 years ago.

Status:
Fixed
Priority:
Normal
Category:
core
Target version:
ASK QUESTIONS IN Forums:

Description

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

Thanks!

Actions #2

Updated by ahasenack over 6 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.

Actions #3

Updated by gstrauss over 6 years ago

  • Category set to core
  • Status changed from New to Fixed
  • Target version changed from 1.4.x to 1.4.46

See the section "signals" in InstallFromSource. Graceful shutdown is already handled with SIGINT, and this is available in existing versions of lighttpd.

Actions

Also available in: Atom