How do i know that jetty started successfully with application instance from an ant target?

回眸只為那壹抹淺笑 提交于 2019-12-12 02:08:55

问题


I face the following problem: whenever i try to start Jetty with an application instance i need check if the application is running. I need to do that from an ant target. I want to have something behaving like the following pseudocode:

**

<target name="target1"
            depends="run-jetty-with-application"
            description="Target1">
        <--when run-jetty-with-application is ok(jetty is up and application is running)-->
        <antcall target="target2"/>
        <--end when-->
    </target>

** I should also mention that i have no publicly exposed urls that could give me the status of the application. I'm not after the hacky solution like waitfor.

Thanks in advance!


回答1:


There are only 2 ways to know if Jetty is started, all webapps are deployed without error, all lifecycle is started successfully, and the server is available to serve content.

  1. Periodically ask for a resource on that web app, confirming that it is up and running. (timeout with failure if resources doesn't make itself available after a period of time)
  2. Hook into the LifeCycle.Listener on the Server component, wait for the .lifeCycleStarted(LifeCycle event) for the server, then walk the entire handler tree, looking for any Handler component that failed to deploy via the DeploymentManager.

As you can imagine, the first technique is the easiest.

This is the <waitfor> facility in Ant, and is what the Jetty project itself uses.

The second approach requires a custom Ant task.

You can either write it yourself, and know that it will do what you want. Or use the jetty-ant tasks with daemon mode to get almost the same thing (the JettyRunTask in daemon mode starts up the server, but it does not wait for start to finish or the webapps to deploy successfully before it returns control to ant).



来源:https://stackoverflow.com/questions/27231413/how-do-i-know-that-jetty-started-successfully-with-application-instance-from-an

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!