Show
Ignore:
Timestamp:
18.04.2012 19:34:18 (8 years ago)
Author:
ak19
Message:

Reinstated the renaming of target stop-tomcat as force-stop-tomcat and its use, along with expanding force-stop-tomcat to wait until tomcat is stopped. This is done by testing a TCP/IP listener at the assigned port for Greenstone using a socket condition.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/build.xml

    r25418 r25420  
    11131113       called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already  
    11141114       stopped as happens when stop-tomcat is called consecutively. --> 
    1115   <target name="stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal"> 
     1115  <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal"> 
    11161116    <exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false"> 
    11171117      <env key="CATALINA_HOME" value="${catalina.home}"/> 
     
    11221122      <arg line=">nul 2>&amp;1"/> 
    11231123    </exec> 
     1124    <!--<antcall target="wait-until-tomcat-stopped"/> 
     1125  </target> 
     1126 
     1127  <target name="wait-until-tomcat-stopped">--> 
     1128    <echo>Waiting for the server to shutdown...</echo> 
     1129    <waitfor maxwait="15" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout"> 
     1130      <socket server="${tomcat.server}" port="${tomcat.port}"/> 
     1131    </waitfor> 
     1132 
     1133    <if> 
     1134      <bool> 
     1135    <isset property="${tomcat.timedout}"/> 
     1136      </bool> 
     1137      <property name="tomcat.isrunning" value="true"/> 
     1138      <echo>WARNING: Checked socket 15 times, but port ${tomcat.port} still busy. Going to try to continue anyway...</echo> 
     1139      <else> 
     1140    <echo>Tomcat is stopped.</echo> 
     1141    <property name="tomcat.isrunning" value="false"/> 
     1142      </else> 
     1143    </if> 
    11241144  </target> 
    11251145 
     
    11271147       And also use a <waitfor> in place of <condition>, such as: 
    11281148       <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor> 
    1129        The http URL resolves to host:port/greenstone3 --> 
     1149       The http URL resolves to host:port/greenstone3  
     1150       Condition uses <http/> rather than <socket/> for testing, since if the server was stopped, the socket  
     1151       might still be in use for some moments. We test the URL with the http condition since it's likelier to 
     1152       fail sooner if the server has indeed been stopped. --> 
    11301153  <target name="check-tomcat-running"> 
    11311154    <condition property="tomcat.isrunning"> 
     
    11341157  </target> 
    11351158 
    1136   <!--<target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning"> 
     1159  <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning"> 
    11371160     <antcall target="force-stop-tomcat"/> 
    1138   </target>--> 
     1161  </target> 
    11391162 
    11401163  <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,start-tomcat"/>