Changeset 25418 for main/trunk


Ignore:
Timestamp:
2012-04-18T15:49:46+12:00 (12 years ago)
Author:
ak19
Message:
  1. Sometimes if tomcat is started and stopped and (re-)started, the check for whether tomcat is running returns the false answer about the state of the server (such as can happen if tomcat is in the process of stopping or starting). As a result, tomcat may not be forcibly stopped when it out to be and this can confuse the user. The force-stop-tomcat target is back to being the stop-tomcat target, but hides any Java Exception output that occurs when the user tries to stop an already-stopped tomcat. 2. The update-userdb target now calls check-tomcat-running in its depends attribute, so that the checking code is not duplicated.
File:
1 edited

Legend:

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

    r25384 r25418  
    11071107
    11081108  <!-- windows: do we want to launch a webrowser?? -->
    1109   <!-- shouldn't this test whether anything is running first? -->
    1110   <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
     1109  <!-- shouldn't this test whether anything is running first?
     1110       It's safer to always attempt to stop tomcat: that way we won't be dependent on the right time
     1111       to check whether the server is stopped or still running before attempting to start again.
     1112       This target, which was recently called force-stop-tomcat for a while but is back to being
     1113       called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already
     1114       stopped as happens when stop-tomcat is called consecutively. -->
     1115  <target name="stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
    11111116    <exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
    11121117      <env key="CATALINA_HOME" value="${catalina.home}"/>
     1118      <arg line=">/dev/null 2>&amp;1"/>
    11131119    </exec>
    11141120    <exec executable="${catalina.home}/bin/shutdown.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="false">
    11151121      <env key="CATALINA_HOME" value="${catalina.home}"/>
    1116     </exec>
    1117   </target>
    1118 
    1119   <target name="check-tomcat-running"><!--if you update this target, may want to change similar elements in config-admin-->
    1120     <!--can also try the "socket" condition in place of the "http" condition-->
    1121     <condition property="tomcat.isrunning"><!--<waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped">-->
    1122       <http url="http://${tomcat.server}:${tomcat.port}${app.path}"/> <!--host:port/greenstone3-->
    1123     </condition><!--</waitfor>-->
    1124   </target>
    1125 
    1126   <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
     1122      <arg line=">nul 2>&amp;1"/>
     1123    </exec>
     1124  </target>
     1125
     1126  <!-- Can also try the "socket" condition in place of the "http" condition
     1127       And also use a <waitfor> in place of <condition>, such as:
     1128       <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor>
     1129       The http URL resolves to host:port/greenstone3 -->
     1130  <target name="check-tomcat-running">
     1131    <condition property="tomcat.isrunning">
     1132      <http url="http://${tomcat.server}:${tomcat.port}${app.path}"/>
     1133    </condition>
     1134  </target>
     1135
     1136  <!--<target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
    11271137     <antcall target="force-stop-tomcat"/>
    1128   </target>
    1129 
     1138  </target>-->
    11301139
    11311140  <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,start-tomcat"/>
     
    12161225    See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
    12171226    But you can do: echo mypassword | ant config-admin -->
    1218   <target name="update-userdb" description="Add or modify users">
    1219     <!-- stop tomcat if running, since derby db is embedded and only allows connections from one jvm instance at a time
    1220       See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html -->
    1221     <!--<antcall target="check-tomcat-running"/>--><!--won't set the tomcat.isrunning property for use below-->
    1222     <condition property="tomcat.isrunning">
    1223       <http url="http://${tomcat.server}:${tomcat.port}${app.path}"/><!--can also try the "socket" condition in place of the "http" condition-->
    1224     </condition>
     1227  <target name="update-userdb" description="Add or modify users" depends="check-tomcat-running">
     1228
     1229    <!-- stop tomcat if running, since derby db is embedded and only allows connections from one jvm instance at a time
     1230     See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
     1231     The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
    12251232    <if>
    12261233      <bool>
    12271234    <istrue value="${tomcat.isrunning}"/>
    12281235      </bool>
    1229       <antcall target="force-stop-tomcat"/>
     1236      <antcall target="stop-tomcat"/>
    12301237    </if>
    12311238
Note: See TracChangeset for help on using the changeset viewer.