Tomcat 8 -XX:OnOutOfMemoryError 无法重启Tomcat

发布于 2025-01-10 23:22:21 字数 638 浏览 5 评论 0原文

发生 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮萍、无处依 2025-01-17 23:22:21

唯一真正有效的是添加 XX:OnOutOfMemoryError,如下所示:

export CATALINA_OPTS="-Xms512m -Xmx1024m -XX:OnOutOfMemoryError='kill -9 %p' "

并使用单独的脚本检查进程是否仍在运行,如果没有则重新启动 Tomcat 实例。

The only thing really works is adding XX:OnOutOfMemoryError as follows:

export CATALINA_OPTS="-Xms512m -Xmx1024m -XX:OnOutOfMemoryError='kill -9 %p' "

and having a separate script checking if the process is still running and if not restart the Tomcat instance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文