检测嵌入式 Jetty 服务器何时完全初始化
我已将 Jetty 嵌入到 java 应用程序中,并在 Jetty 服务器对象的实例上调用 start() 方法(在设置描述静态和动态 Web 内容的位置的处理程序列表之后)。 start() 调用是否会阻塞直到初始化完成? 如果没有,我如何确定服务器何时完全启动并准备好接收请求?
I have embedded Jetty in a java application and am calling the start() method on an instance of the Jetty server object (after setting a handler list which describes the location of the static and dynamic web content). Does the start() call block until initialization is complete? If not, how do I determine when the server is fully started and ready to receive requests?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,当 Server.start() 返回时,服务器已完全初始化。 无需做任何其他事情。 文档并不清楚这种行为,但我只是通过查看代码来验证它。
Yes, the server is completely initialized when Server.start() returns. There's no need to do anything else. The documentation isn't clear about this behavior, but I just verified it by looking at the code.
我们有一个嵌入式 Jetty 应用程序,其中包含数十个要初始化的插件 WARS 和 servlet...我在应用程序启动时从未遇到过浏览器请求超时的情况,因此服务器初始化过程非常快。 来检查 Jetty 服务器是否仍在启动或准备就绪
但是,您可以通过检查HTH
We have an embedded Jetty application with dozens of plug-in WARS and servlets to initialize...I've never had a browser request time out while the app was starting, so the server init process IS pretty fast. However, you can check if the Jetty server is still starting up or ready by checking
HTH
下面是我如何在 ANT 中执行此操作的示例,一旦 jetty 应用程序准备就绪,就启动 Firefox
Here's an example of how I've down this within ANT, launching firefox once the jetty application was ready
不会。它将在后台运行服务器
您使用 org.eclipse.jetty.server.Server#join() 方法。
请参阅 [1] 了解更多信息。
[1] http://www.eclipse.org/jetty /documentation/9.3.x/embedding-jetty.html
No. It will run the server in the background
You use
org.eclipse.jetty.server.Server#join()
method.See [1] fore more info.
[1] http://www.eclipse.org/jetty/documentation/9.3.x/embedding-jetty.html