Monday, September 29, 2008

How to start and stop Tomcat from ANT

start tomcat
<target name="tomcat-start" depends="tomcat-stop">
<java jar="${tomcat.home}/bin/bootstrap.jar" fork="true" spawn="true">
<jvmarg value="-Dcatalina.home=${tomcat.home}"/>
<jvmarg value="-Xms512m"/>
<jvmarg value="-Xmx1024m" />
<jvmarg value="-XX:MaxPermSize=256m"/>
<waitfor maxwait="2" maxwaitunit="minute" checkevery="2000">
<http url="http://${app.server.ip}${server.port}/" />

stop tomcat
<target name="tomcat-stop">
<java jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
<jvmarg value="-Dcatalina.home=${tomcat.home}" />
<arg line="stop" />

Using java task is better than using exec task to call sh or bat file to start/stop tomcat, because java could be executed on both windows and linux.

No comments:

Post a Comment