用户手动重启 Apache 后,systemctl 报告服务失败。无需重启进程,systemd 和 reality 可以同步吗?

用户手动重启 Apache 后,systemctl 报告服务失败。无需重启进程,systemd 和 reality 可以同步吗?

我有一个以 systemd 单元启动的 Apache 实例。用户手动停止并重新启动了该实例。现在 systemctl 报告该服务“失败”。除了停止并重新启动 Apache 之外,还有其他方法可以让 systemd 识别出该服务正在运行吗?

这是状态。(我试图隐藏公司信息,所以如果httpd-apacheINT-1没有意义,那是因为我删除了一部分字符串。)

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

这是我的单位文件。

$ 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

这些是正在运行的进程。

$ 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

其他可能有用的信息。

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

相关内容