'Ant task to install tomcat service'에 해당되는 글 1건

  1. 2010.07.13 Ant task to install tomcat service
Ant task to install tomcat service



First of all let’s do some properties setup:
catalina.home=d:/java/tomcat-6.0.18 tomcat.executable=${catalina.home}/bin/tomcat6.exe tomcat.service.executable=\ ${catalina.home}/bin/service.bat tomcat.service.name=myproject # parameters that will be used in the jvm tomcat.service.jvm.ms=128 tomcat.service.jvm.mx=256
Service startup task consists of 5 exec commands:
  • Stop service if currently running
  • Delete service if installed
  • Install service with bat script
  • Update service with some parameters
  • Start service
Here is the implementation:
<target name="tomcat.service.install" description="Install tomcat service"> <exec command="net stop ${tomcat.service.name}" failifexecutionfails="false" failonerror="false"/> <exec command="${tomcat.executable} //DS//${tomcat.service.name}" failifexecutionfails="false" failonerror="false"/> <exec executable="${tomcat.service.executable}" failifexecutionfails="true" failonerror="true"> <env key="CATALINA_HOME" value="${catalina.home}"/> <arg value="install"/> <arg value="${tomcat.service.name}"/> </exec> <exec executable="${tomcat.executable}"> <arg value="//US//${tomcat.service.name}"/> <arg value="--JvmMs=${jvm.ms}"/> <arg value="--JvmMx=${jvm.mx}"/> <arg value="--Startup=auto"/> </exec> <exec command="net start ${tomcat.service.name}" failifexecutionfails="true" failonerror="true"/> </target>

Posted by [czar]
,