[systemd-devel] lighttp unit - graceful reload of configfiles by sending signal to $MAINPID
lennart at poettering.net
Mon Jan 17 15:41:49 PST 2011
On Tue, 11.01.11 15:46, Marius Tolzmann (tolzmann at molgen.mpg.de) wrote:
> hi again..
> On 01/11/11 11:51, Alexander E. Patrakov wrote:
> >After more research, I found the under-documented lighttpd-angel
> >program. It does what is needed for babysitting lighttpd: performs the
> >"send SIGINT to the old copy and immediately start the new one" dance
> >when it receives SIGHUP. See
> >http://blog.lighttpd.net/articles/2007/09/02/there-is-an-angel-for-lighty .
> >So here is a working unit file for lighttpd, with graceful reloading:
> i found this too but thought is was only intended to be included in
> versions 1.5+ of lighttpd.. after compiling and installing the
> latest lighttpd to test the systemd unit i was happy that the
> "angel" is already shipped in the 1.4.x series.. 8)
> >If you also want graceful stop, you may want to add:
> >ExecStop=/bin/kill -INT $MAINPID
> >but this doesn't work, as lighttpd gets killed immediately. I don't know
> >why this happens.
> have you tried KillMode=process here?
The stop command should be sync, otherweise systemd finds that there is
still process running and will kill it right-away with SIGTERM. That
means lighthttpd will receive first INT and then very likely TERM
too. And KillMode=process will only avoid that the TERM is sent to the
non-main processes, but the main process will still receive two signlas
in most cases.
> >Also, the "test config before reloading" feature still doesn't work
> >right. If I add this ExecReload line before the existing one:
> >ExecReload=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf
> >then systemd will kill lighttpd-angel when the configuration file is
> >bad. It should instead complain to syslog and do nothing with the
> >running instances of lighttpd and lighttpd-angel.
> The behaviour seems to be undocumented (at least i havn't found
> anything) if the ExecReload= command fails.
Hmm, we probably shouldn't shut down the service if a reload fails.
/me adds this to the TODO list.
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel