gpt4 book ai didi

tomcat - Systemd tomcat.service 失败但没有错误

转载 作者:行者123 更新时间:2023-11-28 22:11:29 26 4
gpt4 key购买 nike

我将 Tomcat 配置为在 CentOS 7.2 上使用 Systemd 作为服务运行。我可以毫无问题地启动 Tomcat:

sudo systemctl start tomcat

我可以访问启动画面、管理器应用程序,甚至可以部署应用程序。然后我关闭了 Tomcat:

sudo systemctl stop tomcat

我没有看到任何错误。但后来我检查了状态:

sudo systemctl status tomcat

● tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2016-10-30 17:27:19 UTC; 2s ago
Process: 10833 ExecStop=/bin/kill -TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 10785 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 10795 (code=exited, status=143)

Oct 30 17:26:31 java2016 systemd[1]: Starting Apache Tomcat Web Application Container...
Oct 30 17:26:31 java2016 startup.sh[10785]: Existing PID file found during start.
Oct 30 17:26:31 java2016 startup.sh[10785]: Removing/clearing stale PID file.
Oct 30 17:26:31 java2016 systemd[1]: Started Apache Tomcat Web Application Container.
Oct 30 17:27:19 java2016 systemd[1]: Stopping Apache Tomcat Web Application Container...
Oct 30 17:27:19 java2016 systemd[1]: tomcat.service: main process exited, code=exited, status=143/n/a
Oct 30 17:27:19 java2016 systemd[1]: Stopped Apache Tomcat Web Application Container.
Oct 30 17:27:19 java2016 systemd[1]: Unit tomcat.service entered failed state.
Oct 30 17:27:19 java2016 systemd[1]: tomcat.service failed.

它表明 kill 运行良好。并且 /opt/tomcat/logs/catalina.out 也没有显示任何问题:

30-Oct-2016 17:27:19.268 INFO [Thread-5] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
30-Oct-2016 17:27:19.324 INFO [Thread-5] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
30-Oct-2016 17:27:19.375 INFO [Thread-5] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
30-Oct-2016 17:27:19.491 INFO [Thread-5] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
30-Oct-2016 17:27:19.493 INFO [Thread-5] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
30-Oct-2016 17:27:19.494 INFO [Thread-5] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]
30-Oct-2016 17:27:19.495 INFO [Thread-5] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]

为什么 Systemd 认为 Tomcat“失败”了?它与“过时的 PID 文件”消息有什么关系吗?

最佳答案

啊,没关系;这是answered already on serverfault用于一般 Java 应用程序。

基本上,Java 程序在关闭以响应 SIGTERM 时有时不会发回预期的退出状态。将以下内容添加到 tomcat.service 文件可解决问题:

[Service]
SuccessExitStatus=143

关于tomcat - Systemd tomcat.service 失败但没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40331741/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com