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

查看:651
本文介绍了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失败?

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

推荐答案

啊,没关系;这和 PID文件过时消息有关系吗?对于一般的Java应用程序,已在serverfault上得到答案

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

基本上响应SIGTERM时,Java程序有时不发送预期的退出状态。将以下内容添加到 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天全站免登陆