Tomcat - 以特定顺序启动 webapps [英] Tomcat - starting webapps in a specific order

查看:33
本文介绍了Tomcat - 以特定顺序启动 webapps的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Tomcat 和 Servlet 规范 不支持启动 webapps以特定顺序.

I know that Tomcat and the Servlet spec do not support starting webapps in a particular order.

然而,在我看来,这像是一个常见的用例,我想知道是否有人发现了一个巧妙的解决方法.

However, this seems to me like a common use case, and I'm wondering if someone has discovered a clever workaround for it.

我有 webapp A,它使用 Spring Remoting 来公开一个共享服务,其中 webapp B 是一个客户端.除非 webapp A 正在运行,否则 Webapp B 无法初始化.但是,我的 Tomcat 总是线性启动 webapps,从 webapp B 开始.

I have webapp A which uses Spring Remoting to expose a shared service, of which webapp B is a client. Webapp B cannot initialize unless webapp A is running. However, my Tomcat is always starting the webapps linearly, starting with webapp B.

出于基础架构的原因,我必须让它们在同一台 Tomcat 服务器上运行.

For infrastructure reasons I have to have these running on the same Tomcat server.

有什么想法吗?

谢谢,罗伊

更新 -

事实证明,在我的特殊情况下,顺序并不重要.原因是这样的:假设我使用以下方法之一在应用程序 B 之前启动应用程序 A.所以应用程序 A 启动,但是,由于 Spring 远程处理使用的是 HTTP Invoker,因此 HTTP 端口尚未打开(它不会打开直到所有应用程序启动).所以 A 将启动,B 将挂起,因为它正在寻找的端口尚不可用.嗯.

Turns out that in my particular case, order doesn't matter. The reason is this: say I use one of the methods below to start app A before app B. So app A starts, but, since Spring remoting is using the HTTP Invoker, the HTTP port is not yet open (it won't open until all apps are started). So A will start, and B will hang, because the port it's looking for is not yet available. Doh.

最终结果是两个独立的 Tomcat 实例.

End result was two separate Tomcat instances.

推荐答案

我们有同样的问题,为了解决这个问题,我们依赖于这样一个事实(我知道很滑),即应用程序是按照它们定义的顺序启动的/conf/server.xml.

We have the same problem and to solve it we're relying on the fact (slippery, I know) that applications are started in the order they are defined in <tomcat_home>/conf/server.xml.

这当然有在 server.xml 中硬编码应用程序的缺点,但我们可以忍受它.

This of course has a disadvantage of hardcoding apps in the server.xml but we can live with it.

这篇关于Tomcat - 以特定顺序启动 webapps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆