I want to make a target to restart tomcat6. Right now, I have something like this:
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask" />
<taskdef name="start" classname="org.apache.catalina.ant.StartTask" />
...
<target name="restart" depends="deploy" description="Restart Tomcat" >
<stop url="${manager}" username="${username}" password="${password}" path="${path}" />
<start url="${manager}" username="${username}" password="${password}" path="${path}" />
</target>
Can I rely on stop running before start? Or should I make two separate targets, and have 'start' depend on 'stop'?
In general you can rely on Ant to execute tasks in order. The <start>
is not executed until <stop>
completes.
However given the nature of Tomcat and what it means to "stop Tomcat", what the StopTask
actually does is something like
Therefore, StopTask
can be expected to complete before Tomcat has completed it's shutdown process - the task merely tells Tomcat to shut down, it does not wait for it to shut down.
You'll need some other mechanism in your script to make sure that you don't try to start a Tomcat instance while another instance on the same port is still in the midst of shutting down (such as sleeping an arbitrary number of seconds).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With