I don't think this is fully fixed in resolute.
apache2.service unit:
Environment=APACHE_STARTED_BY_SYSTEMD=true
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl graceful-stop
ExecReload=/usr/sbin/apachectl graceful
# Send SIGWINCH for graceful stop
KillSignal=SIGWINCH
Let's say it's running:
5396 ? Ss 0:00 /usr/sbin/apache2 -k start -DFOREGROUND
5399 ? Sl 0:00 \_ /usr/sbin/apache2 -k start -DFOREGROUND
5400 ? Sl 0:00 \_ /usr/sbin/apache2 -k start -DFOREGROUND
We then stop it, so far so good:
root@r-apachectl:~# apache2ctl stop
Invoking 'systemctl stop apache2'.
Use 'systemctl status apache2' for more info.
root@r-apachectl:~# pidof apache2
root@r-apachectl:~#
systemd is happy:
root@r-apachectl:~# systemctl status apache2
○ apache2.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset:
enabled)
Active: inactive (dead) since Wed 2026-03-25 17:42:26 UTC; 17s ago
...
Then we issue graceful, this is where it breaks:
root@r-apachectl:~# apache2ctl graceful
Invoking 'systemctl reload apache2'.
Use 'systemctl status apache2' for more info.
apache2.service is not active, cannot reload.
The apache2ctl code:
graceful)
if $HTTPD ${APACHE_ARGUMENTS} -t 2> /dev/null ; then
if [ -n "$APACHE_STARTED_BY_SYSTEMD" ] ; then
- this is not entered, because we called apache2ctl directly, so
APACHE_STARTED_BY_SYSTEMD is not set.
# System is using systemd, and the service is reloaded.
# This will never be called if the systemd service is not already
running.
unset APACHE_STARTED_BY_SYSTEMD
exec $HTTPD ${APACHE_ARGUMENTS} -k "$ARGV"
else
if $init_systemd ; then
- This is where we enter:
# If running on systemd we should not directly reload httpd
since
# systemd would be confused about httpd's status.
# (See LP: #1832182 and BTS: #927302)
echo "Invoking 'systemctl reload ${APACHE_SYSTEMD_SERVICE}'."
echo "Use 'systemctl status ${APACHE_SYSTEMD_SERVICE}' for more
info."
systemctl reload "$APACHE_SYSTEMD_SERVICE"
- And systemctl reload is the right call, it would issue "apachectl graceful"
because that's ExecReload in the unit.
- Except systemctl detects that the unit is stopped, so it can't be reloaded:
root@r-apachectl:~# systemctl reload apache2
apache2.service is not active, cannot reload.
root@r-apachectl:~#
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1832182
Title:
systemd unable to detect running apache if invoked via "apache2ctl
graceful"
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/1832182/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs