Tomcat 8 -XX:OnOutOfMemoryError 无法重启Tomcat
发生 OOM 时,我无法自动重新启动 Tomcat 实例。 我尝试了几种不同版本的定义 XX:OnOutOfMemoryError 值:
-XX:OnOutOfMemoryError='kill -9 %p;/application/tomcat/bin/start.sh'"
-XX:OnOutOfMemoryError='kill -9 %p;./application/tomcat/bin/start.sh'"
-XX:OnOutOfMemoryError="kill -9 %p;cd /application/tomcat8/bin/;./application/tomcat8/bin/start.sh"
但无论我尝试什么,start.sh 脚本都永远不会执行,catalina.out 显示:
# java.lang.OutOfMemoryError: Java heap space
# -XX:OnOutOfMemoryError="kill -9 %p;/application/tomcat8/bin/start_commons.sh"
# Executing /bin/sh -c "kill -9 28005"...
Tomcat 实例已成功终止,但之后什么也没有发生。
有什么想法吗?
I'm unable to autorestart a Tomcat instance when an OOM occurs.
I tried several different versions of defining the XX:OnOutOfMemoryError value:
-XX:OnOutOfMemoryError='kill -9 %p;/application/tomcat/bin/start.sh'"
-XX:OnOutOfMemoryError='kill -9 %p;./application/tomcat/bin/start.sh'"
-XX:OnOutOfMemoryError="kill -9 %p;cd /application/tomcat8/bin/;./application/tomcat8/bin/start.sh"
But whatever I try, the start.sh script is never executed, the catalina.out reveals:
# java.lang.OutOfMemoryError: Java heap space
# -XX:OnOutOfMemoryError="kill -9 %p;/application/tomcat8/bin/start_commons.sh"
# Executing /bin/sh -c "kill -9 28005"...
The Tomcat instance is succesfully killed but then nothing happens anymore.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
唯一真正有效的是添加 XX:OnOutOfMemoryError,如下所示:
并使用单独的脚本检查进程是否仍在运行,如果没有则重新启动 Tomcat 实例。
The only thing really works is adding XX:OnOutOfMemoryError as follows:
and having a separate script checking if the process is still running and if not restart the Tomcat instance.