使用 Teamcity 时我的 Tomcat 重新部署失败

发布于 2024-07-16 15:03:57 字数 318 浏览 4 评论 0原文

我正在使用 Teamcity 运行 CI,效果很好,除了一件事:当我的 Web 应用程序部署到 Web 容器 (Tomcat 5.5) 几次后,Tomcat 内存不足。 这也是您在开发中看到的,但这并不是一个大问题,因为您可以以任何方式手动重新启动 - 使用 CI,它都是自动的,这使得它非常烦人。

我尝试设置 Teamcity,以便每次部署时都会重新启动 Tomcat,但随后我遇到了另一个问题 - 从 ant 调用时 Tomcat 启动脚本只是挂起(即,它启动 Tomcat 很好,但随后在构建中不再继续) -过程)。

有人有类似的 Teamcity-Tomcat 设置吗?

I'm using Teamcity to run CI which works great, apart from one thing: when my webapp is deployed to the web container (Tomcat 5.5) after a few times Tomcat runs out of memory. This is something that you see in development as well, but it's not such a huge problem since then you can restart manually any way - with CI it's all automatic which makes it really annoying.

I tried to setup Teamcity so that it restarts Tomcat every deploy, but then I ran into another problem - the Tomcat start script just hangs when called from ant (ie it starts Tomcat just fine, but then doesn't go any further in the build-process).

Anyone out there with a similar Teamcity-Tomcat setup?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

只有一腔孤勇 2024-07-23 15:03:57

这是 tomcat 的问题,类加载器和类没有被正确地垃圾收集。 每次重新加载 webapp 上下文时,都会加载这些类的更多副本,并且由于这些副本存储在永久堆生成中,因此最终会耗尽内存。

您可以在 tomcat 上增加 PermGen 大小启动时,这只会允许您重新部署更多次而不会耗尽内存,这并不是真正的解决方案,但您可以增加部署数量,直到必须重新启动为止。

It's an issue with tomcat, the classloader and the classes are not being garbage collected properly. Every time you reload the webapp context, more copies of these classes are loaded, and as these are stored in the permanent heap generation, it will eventually run out of memory.

You can increase the PermGen size on tomcat startup, this will only allow you to re-deloy more times with out running out of memory, it's not really a fix but you can increase the number of deploys until you'll have to restart.

江南月 2024-07-23 15:03:57

我们遇到了完全相同的问题,正如马克罗宾逊指出的那样,这与类没有被垃圾收集有关。

我们遇到的具体问题是加载大量静态内容:log4j、静态全局变量中填充的 spring 上下文以及创建静态实例或单例的其他类库。

可以使用探查器追踪其中的许多内容,然后在 servlet 的 destroy() 方法中显式处理资源清理。 虽然这并没有完全解决问题,但确实缓解了一些问题。

最后,我们添加了一对额外的 ant 目标来停止和启动 Tomcat,并将构建过程包装在其中。 YMMV。

We had exactly the same issue, and as Mark Robinson points out, it's to do with classes not getting garbage collected.

The particular issue we had was lots of static stuff getting loaded: log4j, spring contexts stuffed in static globals, and other class libraries that created static instances or singletons.

It was possible to trace down a lot of these using a profiler, and then explicitly deal with resource cleanup in the servlet's destroy() method. Although this didn't totally solve the problem, it did relieve some of it.

In the end we added an additional pair of ant targets to stop and start Tomcat, and wrapped the build process in these. YMMV.

泪眸﹌ 2024-07-23 15:03:57

我猜想这个问题并不是 TeamCity 特有的。

如何从 Ant 调用 Tomcat 启动脚本?

如果您使用“exec”任务,您可能需要将“spawn”属性设置为 true,以便它在另一个进程中生成 Tomcat。 否则,Ant 将等待进程结束后再继续。

在我们的部署中,我们有一个脚本来检查 permgen 级别并(可选)在 permgen 太高时重新启动 Tomcat。

I'd guess that this problem isn't specific to TeamCity.

How are you calling the Tomcat startup script from Ant?

If you're using the "exec" task you probably need to set the "spawn" attribute to true so that it spawns Tomcat in another process. Otherwise Ant is waiting for the process to end before it continues.

In our deployments we have a script which checks permgen levels and (optionally) restarts Tomcat if the permgen is too high.

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