[systemd-devel] lighttp unit - graceful reload of configfiles by sending signal to $MAINPID

Marius Tolzmann tolzmann at molgen.mpg.de
Mon Jan 10 09:49:39 PST 2011


hi..

> [Unit]
> Description=Lighttpd Web Server
> After=network.target
>
> [Service]
> Type=forking
> EnvironmentFile=/etc/conf.d/lighttpd
> PIDFile=/var/run/lighttpd.pid
> ExecStartPre=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf
> ExecStart=/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
> ExecStop=/bin/kill -INT $MAINPID
> ExecReload=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf
> ExecReload=/bin/kill -INT $MAINPID
> ExecReload=/bin/sleep 1
> ExecReload=/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
> StandardOutput=syslog
> StandardError=syslog

i still try to get behind all the systemd magic so i have some questions 
on this unit:

can the initial problem of restarting the lighttpd gracefully be solved 
by something like this?:

[Unit]
..
ConditionPathExists=/etc/lighttpd/lighttpd.conf

[Service]
ExecStartPre=/usr/sbin/lighttpd -t ...
ExecStart=/usr/sbin/lighttpd ...
ExecStop=/bin/kill -INT $MAINPID
ExecReload=/usr/sbin/lighttpd -t ...
ExecReload=/bin/kill -INT $MAINPID
StandardOutput=syslog
Restart=on-success ( or on-abort or always .. don't know what the
                      exit-status after graceful kill is in lighty)

and why do you explicitly not use the -D option and let systemd do all 
the forking stuff for you..? you could get rid off the Type= PIDFile= 
lines.. i also removed StandardError=syslog which seems to be redundant 
here..

would this work? or isn't restart intended to be used for those kind of 
things?

SignalStop=SIGINT and SignalReload=SIGINT or something similar may be a 
nice shortcut for doing those kind of things.. Since SignalReload=SIGHUP 
seems to be a way how it is done most of the time?

Another question: Doesn't the default KillMode=control-group would send 
a SIGTERM to the remaining processes of this service immediately after 
the ExecStop= returns and so break the idea behind a graceful shutdown 
where the main-process exits and all running http-requests will be 
finished? (Or is there also a delay of TimeoutSec= between ExecStop= and 
the first SIGTERM?)

..everything is still spinning in my head 8)

marius..


-- 
Dipl.-Inf. Marius Tolzmann <marius.tolzmann at molgen.mpg.de>
----------------------------------.------------------------------
MPI f. molekulare Genetik         |
Ihnestrasse 63-73, D-14195 Berlin |   ==> MarIuX GNU/Linux <==
Phone: +49 (0)30 8413 1709        |
----------------------------------^------------------------------
God put me on earth to accomplish a certain number of things.
Right now I am so far behind..
    ..I will never die.         <by calvin from calvin&hobbes ;)>




More information about the systemd-devel mailing list