Most systemd-based distributions use a patched apachectl
script [1] that delegates commands to systemctl
. The patched apachectl
command does not support the "pass-through" mode of operation in which arguments are passed through to httpd
. The apachectl manual page reflects the upstream non-patched apachectl
command, hence the discrepancy.
I recommend using the systemctl
[2] abstraction for starting and stopping services.
Thus, to gracefully restart the Apache HTTP Server on Centos 7, and other linux distributions using systemd, use:
sudo systemctl reload httpd.service
Under the hood, this invokes httpd -k graceful
. You can verify this with this command:
$ systemctl cat httpd.service | grep -F ExecReload
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
To stop the Apache HTTP Server:
sudo systemctl stop httpd.service
which, behind the scenes, sends a SIGWINCH
signal to the httpd
process.
This can be verified with this command:
$ systemctl cat httpd.service \
| grep -E --before-context=1 'ExecStop|KillSignal'
# Send SIGWINCH for graceful stop
KillSignal=SIGWINCH
The systemd.service
[3] manual says that in this situation, where the ExecStop
option is not specified, "the process is terminated by sending the signal specified in KillSignal
."
Why SIGWINCH
? Because, per https://bz.apache.org/bugzilla/show_bug.cgi?id=50669 , Apache uses the SIGWINCH
signal as a 'graceful shutdown' trigger.
Another command you may find useful to explore service options is the show
command combined with -p, --property
options, like this:
$ systemctl show httpd.service -p ExecStart -p ExecReload -p ExecStop -p KillSignal
[1] https://git.centos.org/blob/rpms!httpd.git/c7/SOURCES!httpd-2.4.3-apctl-systemd.patch
[2] https://www.freedesktop.org/software/systemd/man/systemctl.html
[3] https://www.freedesktop.org/software/systemd/man/systemd.service.html