We are using the tomcat ant tasks to deploy our applications to both tomcat6 and tomcat7. For both though, we see a problem that when tomcat is out of memory (due to bad setup, I know), pa开发者_开发知识库ge request hang in there and don't fail.
Problem though is that this also hangs our ant tasks, which I believe just use http like the browser does.
So I'm curious how I could first check in ant if the server is running, or perhaps set a timeout on the deploy tasks?
Thanks
I'm not sure how you can check the server is running and avoid the connection hanging, but you can run an Ant task that times out. You can do this by means of the parallel task - which you would normally use to execute build steps simultaneously. The task has a timeout (milliseconds) setting. For example:
<target name="tomcat_task">
<parallel threadCount="1" timeout="10000">
<sequential>
... tomcat task here ...
</sequential>
</parallel>
</target>
精彩评论