Systemd tomcat.service 失败,没有错误 [英] Systemd tomcat.service failed with no errors

查看:21
本文介绍了Systemd tomcat.service 失败,没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have Tomcat configured to run as a service using Systemd on CentOS 7.2. I can start Tomcat with no problems:

sudo systemctl start tomcat

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

I can access the splash screen, the manager app, and even deploy applications. Then I shut down Tomcat:

sudo systemctl stop tomcat

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

I don't see any errors. But then I check the status:

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 也没有显示任何问题:

It shows that kill functioned just fine. And /opt/tomcat/logs/catalina.out doesn't show any problems, either:

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 文件"消息有什么关系吗?

Why does Systemd consider Tomcat "failed"? Does it have anything to do with that "stale PID file" message?

推荐答案

啊,没关系;对于一般 Java 应用程序,已经在 serverfault 上回答了.

Ah, never mind; this has been answered already on serverfault for general Java applications.

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

Basically Java programs sometimes don't send back the expected exit status when shutting down in response to SIGTERM. Adding the following to the tomcat.service file fixes the problem:

[Service]
SuccessExitStatus=143

这篇关于Systemd tomcat.service 失败,没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆