You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Philip Aston <pa...@bea.com> on 2003/02/11 15:47:31 UTC

Re: pingURL: A better way to start and stop application servers?


Philip Aston writes last April:
 > [old thread, I've been busy]

Positively historic now.

 > Steve Loughran writes:
 >  > You can use <waitfor> to probe a url with controlled sleep time
 >  > and timeout interval, sets a property on success, etc.
 >  > 
 >  > All pingurl does is add a container wrapper, but it only allows
 >  > url 2XX conditions to be evaluated (presumably); <waitfor> can
 >  > probe any port for being openable, plus all the other conditions
 >  > that are possible
 > 
 > Yep, waitfor is more generic and wins. Roll on 1.5 :-)

I _finally_ got around to trying this. I used something like:

      <target name="start-server">
	<parallel>
	  <sequential>
	    <java><!-- start server --></java>
	  </sequential>

	  <waitfor><http url="http://localhost:7001/"/></waitfor>
	</parallel>
      </target>

However, this doesn't do the same as:

      <target name="start-server">
	 <pingURL testURL="http://localhost:7001/" waitUntil="alive">
	   <java><!-- start server --></java>
         </pingURL>
      </target>

The difference between the two is that the <parallel> construct does
not exit until the server exits, whereas pingURL launches the "start
server" work in its own thread. With pingURL I can have my unit test
targets depend on start-server. AFAICS, I can't achieve the same with
standard ANT tasks.

As a random suggestion, perhaps there could be a "asynchronous" option
for <java> so you could do:

   <java asynchronous="true"><!-- start server --></java>
   <waitfor><http url="http://localhost:7001/"/></waitfor>

Any comments?

- Phil