Re: httpd + systemd

2016-02-26 Thread Reindl Harald



Am 26.02.2016 um 17:11 schrieb Tim Bannister:

On 26 February 2016, Reindl Harald wrote:




in case of a SIGTERM the daemon is supposed to do a clean shutdown
anyways

[Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS -D FOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
Restart=always
RestartSec=1


Maybe add an ExecStop as well which calls graceful-stop? This is more reliable 
than a signal.

After DefaultTimeoutStopSec seconds, systemd will intervene regardless


it works not the way you likely think and may make things worser than a 
controlled SIGTERM


https://www.freedesktop.org/software/systemd/man/systemd.service.html

Note that it is usually not sufficient to specify a command for this 
setting that only asks the service to terminate (for example, by queuing 
some form of termination signal for it), but does not wait for it to do 
so. Since the remaining processes of the services are killed using 
SIGKILL immediately after the command exited, this would not result in a 
clean stop. The specified command should hence be a synchronous 
operation, not an asynchronous one.




signature.asc
Description: OpenPGP digital signature


Re: httpd + systemd

2016-02-26 Thread Tim Bannister
On 26 February 2016, Reindl Harald wrote:
>
>
>
>in case of a SIGTERM the daemon is supposed to do a clean shutdown
>anyways
>
>[Service]
>Type=simple
>EnvironmentFile=-/etc/sysconfig/httpd
>ExecStart=/usr/sbin/httpd $OPTIONS -D FOREGROUND
>ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
>Restart=always
>RestartSec=1
>
Maybe add an ExecStop as well which calls graceful-stop? This is more reliable 
than a signal.

After DefaultTimeoutStopSec seconds, systemd will intervene regardless.
-- 
Tim Bannister – is...@c8h10n4o2.org.uk


Re: httpd + systemd

2016-02-26 Thread Reindl Harald



Am 26.02.2016 um 10:57 schrieb Graham Leggett:

Hi all,

I am trying to come up with a vanilla systemd unit file so that our RPM 
packaging contains a sensible startup on systemd environments, but I’m 
struggling.

With the unit file below the “systemctl restart httpd” command hangs. Usually 
the server starts fine, but then the server is stopped by something a short 
while afterwards for no clear reason. According to google the hang in systemctl 
happens for many people, systemctl is waiting for a message that never comes, 
but the causes are widely varied and I am struggling to figure out exactly what 
is wrong.

What I am trying to achieve is a simple daemon start, with no mod_systemd 
(which isn’t part of core httpd).

Can anyone point out any obvious errors in the following?


i would recommend the following which is in use here starting in 2012 on 
all servers, with the no-forking the mainpid for systemd is clear and by 
stop the service all processes get a SIGTERM from systemd


that works also with mpm-prefork perfectly (we use prefork)

while i understand the "give httpd some time to finish gracefully" in 
case of a hard restart it has the drawback that new connections are not 
accepted for that time-period and so it has negative impact


in case of a SIGTERM the daemon is supposed to do a clean shutdown anyways

[Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS -D FOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
Restart=always
RestartSec=1


[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=forking
PIDFile=/var/run/httpd.pid
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target




signature.asc
Description: OpenPGP digital signature


httpd + systemd

2016-02-26 Thread Graham Leggett
Hi all,

I am trying to come up with a vanilla systemd unit file so that our RPM 
packaging contains a sensible startup on systemd environments, but I’m 
struggling.

With the unit file below the “systemctl restart httpd” command hangs. Usually 
the server starts fine, but then the server is stopped by something a short 
while afterwards for no clear reason. According to google the hang in systemctl 
happens for many people, systemctl is waiting for a message that never comes, 
but the causes are widely varied and I am struggling to figure out exactly what 
is wrong.

What I am trying to achieve is a simple daemon start, with no mod_systemd 
(which isn’t part of core httpd).

Can anyone point out any obvious errors in the following?

[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=forking
PIDFile=/var/run/httpd.pid
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Regards,
Graham
—