Changeset 29988

Show
Ignore:
Timestamp:
22.06.2015 19:42:38 (5 years ago)
Author:
ak19
Message:

1. Targets for stopping and starting the derby server now first check whether derby is already running and acts accordingly, just like stop-tomcat does, with the introduction of a force-stop-derby. 2. Have added a similar check for start-tomcat, so that we can't any longer accidentally run ant start and thereby run two tomcat instances on the same host and port.

Location:
main/trunk/greenstone3
Files:
2 modified

Legend:

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

    r29977 r29988  
    787787  <target name="get-default-servlet-url"> 
    788788    <echo>http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}</echo> 
    789   </target>  
    790    
    791   <target name="start-derby-java"> 
    792     <echo>Launching derby on ${derby.server}:${derby.server.port}...</echo> 
    793     <java classname="org.apache.derby.drda.NetworkServerControl" fork="true" spawn="true" clonevm="true">       
    794       <arg value="start"/> 
    795       <classpath refid="derby.server.classpath"/> 
    796     </java> 
     789  </target>  
     790 
     791  <target name="check-derbyserver-running"> 
     792    <condition property="derby.isrunning" value="true" else="false"> 
     793      <!--<socket server="jdbc:derby://${derby.server}" port="${derby.server.port}"/>--> 
     794      <socket server="${derby.server}" port="${derby.server.port}"/><!-- like telnet machine port --> 
     795    </condition> 
     796    <echo>Derby is running: ${derby.isrunning}</echo> 
     797  </target> 
     798 
     799  <target name="start-derby-java" depends="check-derbyserver-running"> 
     800    <if><bool><not><istrue value="${derby.isrunning}"/></not></bool> 
     801      <echo>Launching derby on ${derby.server}:${derby.server.port}...</echo> 
     802      <java classname="org.apache.derby.drda.NetworkServerControl" fork="true" spawn="true" clonevm="true">       
     803    <arg value="start"/> 
     804    <classpath refid="derby.server.classpath"/> 
     805      </java> 
     806      <else> 
     807    <echo>Derby server ALREADY RUNNING on ${derby.server}:${derby.server.port}</echo> 
     808      </else> 
     809    </if> 
    797810  </target> 
    798811   
    799812  <!-- Using derby 10.1.2.1 
    800813       See db-derby-10.1.2.1-bin/docs/html/adminguide/index.html --> 
    801   <target name="start-derby"> 
    802     <echo>About to launch derby on ${derby.server}:${derby.server.port}</echo> 
    803     <property name="derby.server.classpath.prop" refid="derby.server.classpath" /> 
    804  
    805     <exec executable="java" spawn="true"><!-- failonerror="true"--> 
    806       <env key="CLASSPATH" path="${derby.server.classpath.prop}"/> 
    807       <arg value="org.apache.derby.drda.NetworkServerControl"/> 
    808       <arg value="start"/> 
    809       <arg value="-p"/> 
    810       <arg value="${derby.server.port}"/> 
    811     </exec>    
    812   </target> 
    813  
    814   <target name="stop-derby"> 
     814  <target name="start-derby" depends="check-derbyserver-running"> 
     815    <if><bool><not><istrue value="${derby.isrunning}"/></not></bool> 
     816      <echo>About to launch derby on ${derby.server}:${derby.server.port}</echo> 
     817      <property name="derby.server.classpath.prop" refid="derby.server.classpath" /> 
     818       
     819      <exec executable="java" spawn="true"><!-- failonerror="true"--> 
     820    <env key="CLASSPATH" path="${derby.server.classpath.prop}"/> 
     821    <arg value="org.apache.derby.drda.NetworkServerControl"/> 
     822    <arg value="start"/> 
     823    <arg value="-p"/> 
     824    <arg value="${derby.server.port}"/> 
     825      </exec> 
     826      <else> 
     827    <echo>Derby networked server ALREADY RUNNING on ${derby.server}:${derby.server.port}</echo> 
     828      </else> 
     829    </if> 
     830  </target> 
     831 
     832  <target name="force-stop-derby"> 
    815833    <java classname="org.apache.derby.drda.NetworkServerControl"> 
    816834      <arg value="shutdown"/> 
    817835      <classpath refid="derby.server.classpath"/> 
    818836    </java> 
     837  </target> 
     838 
     839  <target name="stop-derby" description="Shutdown derby server only if running" depends="check-derbyserver-running"><!-- if="${derby.isrunning}" checks if true or false only from ant 1.8 on --> 
     840    <if><bool><istrue value="${derby.isrunning}"/></bool> 
     841      <!--<echo>Derby is |${derby.isrunning}| running</echo>--> 
     842      <antcall target="force-stop-derby"/> 
     843      <else> 
     844    <echo>Derby is not running</echo> 
     845      </else> 
     846    </if> 
    819847  </target> 
    820848 
     
    14881516 
    14891517  <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ --> 
    1490   <target name="start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal"> 
     1518  <target name="start-tomcat" description="Startup only Tomcat" depends="init,check-tomcat-running" if="tomcat.islocal"> 
     1519    <if><bool><istrue value="${tomcat.isrunning}"/></bool> 
     1520      <echo>**************************************</echo> 
     1521      <echo>A TOMCAT IS ALREADY RUNNING ON http://${tomcat.server}:${tomcat.port}. NOT STARTING.</echo> 
     1522      <echo>**************************************</echo> 
     1523      <else> 
    14911524    <property name="tomcat.classpath" refid="local.tomcat.classpath"/> 
    14921525    <property name="tomcat.path" refid="local.tomcat.path"/> 
     
    15371570      </and> 
    15381571    </waitfor> 
     1572 
     1573   </else> 
     1574   </if> 
    15391575  </target> 
    15401576 
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server3.java

    r29923 r29988  
    3030        RESTART_CMD = "restart"; 
    3131        CONFIGURE_CMD = "configure"; 
    32         STOP_CMD = "force-stop-tomcat stop-derby"; 
     32        STOP_CMD = "force-stop-tomcat force-stop-derby"; 
    3333 
    3434        String is_read_only = System.getProperty("gsdl3home.isreadonly","false");