【问题标题】:debug onoutofmemory unable to start tomcat调试onoutofmemory无法启动tomcat
【发布时间】:2017-10-10 16:47:10
【问题描述】:

我可以选择在内存不足时重新启动 tomcat。

-XX:OnOutOfMemoryError=/opt/tomcat/bin/restart.sh

这里是restart.sh

#!/bin/bash

pkill -9 -f tomcat
/opt/tomcat/bin/startup.sh

Tomcat 执行脚本,杀死 tomcat,但不再重新启动它。这是日志

java.lang.OutOfMemoryError: Java heap space
# -XX:OnOutOfMemoryError="/opt/tomcat/bin/restart.sh"
#   Executing /bin/sh -c "/opt/tomcat/bin/restart.sh"...

请帮我调试一下为什么tomcat不重启。

【问题讨论】:

  • 我不知道为什么有人会投票 - 在没有正确阅读的情况下关闭。有点傻。似乎tomcat执行脚本并坐在那里。如果我手动运行脚本,它完全可以正常工作
  • -XX:OnOutOfMemoryError 应该是 JVM 还是 Tomcat 选项? Google 未返回任何结果。
  • 如果脚本在子进程中运行,它可能会与 tomcat 一起被杀死。您可以在 kill 前后添加一些回声线来测试这个假设。
  • @M.leRutte 。是的,这是一个 java 选项。

标签: java tomcat out-of-memory tomcat8


【解决方案1】:

我没有找到这个问题的答案,但我最终每 2 分钟对 tomcat 运行一次健康检查,这解决了我在内存不足时手动重新启动 tomcat 的问题。

【讨论】:

    猜你喜欢
    • 2014-09-12
    • 2013-07-25
    • 2015-11-25
    • 2013-02-01
    • 2015-04-17
    • 2016-04-22
    • 1970-01-01
    相关资源
    最近更新 更多