Now let's check the bug claim, on questing:

root@q-apachectl:~# pidof apache2
4640 4639 4317
root@q-apachectl:~# apache2ctl stop
root@q-apachectl:~# pidof apache2
root@q-apachectl:~# 

[Fri Mar 27 18:02:29.924281 2026] [mpm_event:notice] [pid 4317:tid 4317]
AH00491: caught SIGTERM, shutting down

root@q-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 Fri 2026-03-27 18:02:30 UTC; 30s ago
   Duration: 8min 27.796s
 Invocation: 5e1fbc43f9784b3bb76295aa3975c749
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 4314 ExecStart=/usr/sbin/apachectl start (code=exited, 
status=0/SUCCESS)
    Process: 4776 ExecStop=/usr/sbin/apachectl graceful-stop (code=exited, 
status=0/SUCCESS)
   Main PID: 4317 (code=exited, status=0/SUCCESS)
   Mem peak: 5.7M
        CPU: 184ms

Mar 27 17:54:02 q-apachectl systemd[1]: Starting apache2.service - The Apache 
HTTP Server...
Mar 27 17:54:02 q-apachectl systemd[1]: Started apache2.service - The Apache 
HTTP Server.
Mar 27 18:02:30 q-apachectl apachectl[4778]: httpd (no pid file) not running
Mar 27 18:02:30 q-apachectl systemd[1]: apache2.service: Deactivated 
successfully.


So far, so good. All in sync.

The difference comes now when we call graceful in this state, with no
apache running:

root@q-apachectl:~# pidof apache2
root@q-apachectl:~# apache2ctl graceful
httpd not running, trying to start
root@q-apachectl:~# pidof apache2
4798 4797 4796
root@q-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 Fri 2026-03-27 18:02:30 UTC; 1min 23s ago
   Duration: 8min 27.796s
 Invocation: 5e1fbc43f9784b3bb76295aa3975c749
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 4314 ExecStart=/usr/sbin/apachectl start (code=exited, 
status=0/SUCCESS)
    Process: 4776 ExecStop=/usr/sbin/apachectl graceful-stop (code=exited, 
status=0/SUCCESS)
   Main PID: 4317 (code=exited, status=0/SUCCESS)
   Mem peak: 5.7M
        CPU: 184ms

Mar 27 17:54:02 q-apachectl systemd[1]: Starting apache2.service - The Apache 
HTTP Server...
Mar 27 17:54:02 q-apachectl systemd[1]: Started apache2.service - The Apache 
HTTP Server.
Mar 27 18:02:30 q-apachectl apachectl[4778]: httpd (no pid file) not running
Mar 27 18:02:30 q-apachectl systemd[1]: apache2.service: Deactivated 
successfully.

"graceful" will start the service if it's not running. And that happens
in such a way that systemd doesn't know about it.

What I don't understand now is the claim from the description of this
bug:

> Unattended upgrade will attempt to gracefully reload the Apache2 httpd
service

unattended-upgrades does not care about individual services like that. It just 
updates the packages.
There is no "apache2ctl" or "apachectl" in that script.

There is a mix of init.d and systemd controls, though, and this can get
confusing because /etc/init.d/apache2 is shipped with this package, but
not used because invoke-rc.d is called with --skip-systemd-native.

So we are just using systemd, and the restart action is a graceful
restart which we already covered and doesn't leave things out of sync.


This bug says that unattended upgrades somehow trigger these calls directly:
# apache2ctl stop
# apache2ctl graceful

But via package upgrades, systemctl is used, and it works just fine.

So we are left with the scenario where someone runs these valid
commands, and that does indeed leads to systemd thinking the service is
not running. But as far as I can see, it's not a simple package upgrade,
or unattended upgrades, unless I missed something.

-- 
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

Reply via email to