I have an Apache instance that starts with a systemd unit. A user manually stopped and restarted the instance. Now systemctl reports the service as "failed". Other than stopping and restarting Apache, is there a way to get systemd to recognize the service is running?
This is the status. (I've tried to hide the company information, so if httpd-apache
and INT-1
don't make sense, it's because I've removed a part of the character string.)
$ systemctl status httpd-apache-int-1.service
* httpd-apache.service - The Apache HTTP Server for the INT-1 Instance
Loaded: loaded (/usr/lib/systemd/system/httpd-apache-int-1.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2022-05-04 15:56:39 CDT; 2 days ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 26914 (code=exited, status=0/SUCCESS)
This is my unit file.
$ systemctl cat httpd-apache-int-1.service
# /usr/lib/systemd/system/httpd-apache-int-1.service
[Unit]
Description=The Apache HTTP Server for the INT-1 Instance
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=forking
# ExecStart isn't the "systemd way" of doing things.
# There may be problems with things like running more
# than one "systemctl ACTION httpd-apache-int-1"
# at a time. But using Environment(File) and
# systemd override just aren't doing what I want.
ExecStart=/bin/sh -c '\
source /etc/sysconfig/httpd.int-1 ; \
source /opt/ca/webagent/ca_wa_env.sh ; \
source /opt/apache/etc/int-1/WebAgent.conf ; \
/usr/sbin/httpd $OPTIONS ; \
exit 0'
ExecReload=/bin/kill -USR1 ${MAINPID}
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
These are the running processes.
$ ps -ef | grep [i]nt-1
apache 1030 27237 0 14:30 ? 00:00:01 /usr/sbin/httpd -k start -f /opt/apache/etc/int-1/httpd.conf
apache 3291 27237 0 May05 ? 00:00:12 /usr/sbin/httpd -k start -f /opt/apache/etc/int-1/httpd.conf
apache 9974 27237 0 May05 ? 00:00:15 /usr/sbin/httpd -k start -f /opt/apache/etc/int-1/httpd.conf
root 27237 1 0 May04 ? 00:00:05 /usr/sbin/httpd -k start -f /opt/apache/etc/int-1/httpd.conf
apache 27239 1 0 May04 ? 00:07:00 LLAWP /opt/apache/etc/int-1/WebAgent.conf -APACHE24
apache 27261 27237 0 May04 ? 00:00:41 /usr/sbin/httpd -k start -f /opt/apache/etc/int-1/httpd.conf
apache 27262 27237 0 May04 ? 00:00:37 /usr/sbin/httpd -k start -f /opt/apache/etc/int-1/httpd.conf
Other information that might be useful.
Apache
Server version: Apache/2.4.6 (Red Hat Enterprise Linux)
OS
Red Hat Enterprise Linux Server release 7.9 (Maipo)
$ systemctl --version
systemd 219