Changeset 32334

Show
Ignore:
Timestamp:
14.08.2018 15:50:12 (11 months ago)
Author:
ak19
Message:

All the changes (still preliminary) that use tomcat.https.port and tomcat.http.port to determine tomcat.port and write it out to build.xml. Now the server application won't quite work: it can't change the port numbers as its code only knows to write out the tomcat.port, and the actual tomcat port (https or http) will remain unaffected. But I'll fix this later, as there may be a better way to do this.

Location:
main/trunk/greenstone3
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/build.properties.svn

    r32309 r32334  
    1111# but not remotely 
    1212tomcat.server=localhost 
    13 # The port number that tomcat is/will be run on 
    14 tomcat.port=8383 
     13tomcat.http.port=8383 
     14tomcat.https.port=8443 
    1515# Tomcat's shutdown port - this may need to be changed if you are running two or more Tomcats 
    1616tomcat.shutdown.port=8305 
     
    161161##listing and description of all the web services deployable on GS3## 
    162162web.services.list=${base.webservice.name} for Greenstone3's core web services, QBR${base.webservice.name} for Query, Browse and Retrieve services 
     163 
     164## ------------------------------------------------------ ## 
     165## Do not modify any properties that appear after this 
     166## as they are automatically generated. 
     167## ------------------------------------------------------ ## 
     168 
     169## The port number that tomcat is/will run on by default (i.e. for the default server.protocol value set) 
  • main/trunk/greenstone3/build.xml

    r32333 r32334  
    100100  <if><bool><available file="${user.home}/build.properties"/></bool> 
    101101    <property file="${user.home}/build.properties"/> 
     102  </if> 
     103 
     104 
     105  <!-- If internal.tomcat.port not yet set, work it out based on server.protocol  
     106       Would be great if we could just use nested variables in build.properties 
     107       https://grokbase.com/t/ant/user/04698xjbp3/nested-variables-in-ant 
     108       http://ant.apache.org/faq.html#propertyvalue-as-name-for-property 
     109       https://marc.info/?l=ant-user&m=111231719328847 
     110       http://ant-contrib.sourceforge.net/tasks/tasks/propertycopy.html 
     111       http://www.jguru.com/faq/view.jsp?EID=1072238 
     112       * propfile: 
     113       https://ant.apache.org/manual/Tasks/propertyfile.html 
     114       * valid ports range from 1024–49151 
     115       https://stackoverflow.com/questions/113224/what-is-the-largest-tcp-ip-network-port-number-allowable-for-ipv4 
     116  --> 
     117 
     118  <!-- If internal.tomcat.port not yet set, work it out based on server.protocol  
     119       Would be great if we could just use nested variables in build.properties 
     120       https://grokbase.com/t/ant/user/04698xjbp3/nested-variables-in-ant 
     121       http://ant.apache.org/faq.html#propertyvalue-as-name-for-property 
     122       https://marc.info/?l=ant-user&m=111231719328847 
     123       http://ant-contrib.sourceforge.net/tasks/tasks/propertycopy.html 
     124       http://www.jguru.com/faq/view.jsp?EID=1072238 
     125       * propfile: 
     126       https://ant.apache.org/manual/Tasks/propertyfile.html 
     127       * valid ports range from 1024–49151 
     128       https://stackoverflow.com/questions/113224/what-is-the-largest-tcp-ip-network-port-number-allowable-for-ipv4 
     129  --> 
     130  <!--<if> 
     131    <bool><not><isset property="internal.tomcat.port"/></not></bool>--> 
     132    <if> 
     133      <bool> 
     134    <not> 
     135      <or> 
     136        <and> 
     137          <equals arg1="${server.protocol}" arg2="http" trim="true" casesensitive="false" forcestring="true"/>         
     138          <isset property="tomcat.http.port"/>         
     139          <matches string="${tomcat.http.port}" pattern="^\d{3,4}\s*$"/> 
     140        </and> 
     141        <and> 
     142          <equals arg1="${server.protocol}" arg2="https" trim="true" casesensitive="false" forcestring="true"/>        
     143          <isset property="tomcat.https.port"/> 
     144          <matches string="${tomcat.https.port}" pattern="^\d{3,4}\s*$"/> 
     145        </and> 
     146      </or> 
     147    </not> 
     148      </bool> 
     149      <fail>ERROR: Unable to set tomcat.port. 
     150      In file build.properties server.protocol=${server.protocol} and requires at minimum that its 
     151      matching tomcat.${server.protocol}.port property line be set and is assigned a valid port number. 
     152      (Ensure any other enabled tomcat port is valid too)</fail> 
     153      <!--<echo>Uncomment at least the tomcat.${server.protocol}.port line in build.properties.</echo>--> 
     154      <!--<property name="internal.tomcat.port" value=""/>-->       
     155      <else> 
     156    <condition property="internal.tomcat.port" value="${tomcat.https.port}" else="${tomcat.http.port}"> 
     157      <equals arg1="${server.protocol}" arg2="https" trim="true" casesensitive="false" forcestring="true"/> 
     158    </condition> 
     159      </else> 
     160    </if> 
     161  <!--</if>--> 
     162 
     163  <!-- Set autogenerated properties (properties we calculate here in build.xml) 
     164       in build.properties. https://ant.apache.org/manual/Tasks/propertyfile.html 
     165       For now only internal.tomcat.port is determined by build.xml 
     166       and written out to build.properties as tomcat.port. 
     167       Internally, this file still uses internal.tomcat.port as any old value 
     168       read in from build.properties for tomcat.port can't be changed in memory 
     169       even though we can write it back out again to build.properties. 
     170  --> 
     171  <if> 
     172    <bool><isset property="internal.tomcat.port"/></bool> 
     173    <propertyfile file="build.properties"> 
     174      <entry key="tomcat.port" value="${internal.tomcat.port}"/> 
     175    </propertyfile> 
    102176  </if> 
    103177 
     
    851925 
    852926  <target name="get-default-servlet-url"> 
    853     <echo>${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}</echo> 
     927    <echo>${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}${server.default.servlet}</echo> 
    854928  </target> 
    855929 
    856930  <target name="get-solr-servlet-url"> 
    857     <echo>${server.protocol}://${tomcat.server}:${tomcat.port}/${solr.context}</echo> 
     931    <echo>${server.protocol}://${tomcat.server}:${internal.tomcat.port}/${solr.context}</echo> 
    858932  </target> 
    859933 
     
    9451019    </if> 
    9461020    <if><bool><isset property="install.flax"/></bool> 
    947         <property name="url" value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/flax"/> 
     1021        <property name="url" value="${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}/flax"/> 
    9481022    <else> 
    949         <property name="url" value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/"/> 
     1023        <property name="url" value="${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}/"/> 
    9501024    </else> 
    9511025    </if> 
     
    10001074  <target name="accept-properties" unless="properties.accepted"> 
    10011075    <input addproperty="properties.ok" validargs="y,n">The following properties (among others) are being used from a build.properties file found in this directory: 
     1076      server.protocol=${server.protocol} 
    10021077      tomcat.server=${tomcat.server} 
    1003       tomcat.port=${tomcat.port}  
     1078      <!--tomcat.port=${internal.tomcat.port}--> 
     1079      tomcat.http.port=${tomcat.http.port} 
     1080      tomcat.https.port=${tomcat.https.port} 
    10041081      tomcat.installed.path=${tomcat.installed.path} (this is the location of Tomcat's base dir if it is already installed) 
    10051082      proxy.host=${proxy.host} 
     
    10141091  </target> 
    10151092   
     1093  <!-- Need to list this first in depends for any target that will be using internal.tomcat.port --> 
     1094  <target name="tomcat-init"> 
     1095    <if> 
     1096      <bool><not><isset property="internal.tomcat.port"/></not></bool> 
     1097      <fail>ERROR: no tomcat port, so tomcat operations won't proceed. 
     1098      tomcat.${server.protocol}.port is not set or not valid. 
     1099      Correct this in build.properties.</fail> 
     1100    </if> 
     1101  </target> 
     1102 
     1103 
    10161104  <!-- this sets up some initial properties --> 
    10171105  <target name="init"> 
     
    10381126    </condition> 
    10391127     
    1040     <echo>tomcat.port = ${tomcat.port}</echo> 
     1128    <echo>internal.tomcat.port = ${internal.tomcat.port}</echo> 
    10411129 
    10421130    <condition property="proxy.present"> 
     
    13271415  </target> 
    13281416 
    1329   <target name="configure-web" depends="init,perl-for-building" 
     1417  <target name="configure-web" depends="tomcat-init,init,perl-for-building" 
    13301418    description="Configure only the web app config files"> 
    13311419    <!-- we want a unix path in the global.properties file --> 
     
    13471435    <filter token="gsdl3writablehome" value="${src.gsdl3.writablehome.unix}"/> 
    13481436    <filter token="gsdl3version" value="${app.version}"/> 
     1437    <filter token="server.protocol" value="${server.protocol}"/> 
    13491438    <filter token="tomcat.server" value="${tomcat.server}"/> 
    1350     <filter token="tomcat.port" value="${tomcat.port}"/> 
     1439    <filter token="tomcat.port" value="${internal.tomcat.port}"/> 
     1440    <filter token="tomcat.http.port" value="${tomcat.http.port}"/> 
     1441    <filter token="tomcat.https.port" value="${tomcat.https.port}"/> 
    13511442    <filter token="greenstone.context" value="${greenstone.context}"/> 
    13521443    <filter token="derbyserver" value="${derby.server}"/> 
     
    14941585  <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/> 
    14951586   
    1496   <target name="configure-tomcat-local" depends="init,perl-for-building" if="tomcat.islocal"> 
     1587  <target name="configure-tomcat-local" depends="tomcat-init,init,perl-for-building" if="tomcat.islocal"> 
    14971588    <!-- re-setup the server.xml file --> 
    14981589    <copy file="${basedir}/resources/tomcat/server_tomcat${tomcat.version.major}.xml.in" 
    14991590        tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true"> 
    15001591      <filterset> 
    1501         <filter token="port" value="${tomcat.port}"/> 
     1592        <filter token="port" value="${internal.tomcat.port}"/> 
    15021593        <filter token="shutdown-port" value="${tomcat.shutdown.port}"/> 
    15031594      </filterset> 
     
    15751666       on how to use this with eclipse 
    15761667    --> 
    1577   <target name="debug-start-tomcat" description="Startup Tomcat for debugger" depends="init" if="tomcat.islocal"> 
     1668  <target name="debug-start-tomcat" description="Startup Tomcat for debugger" depends="tomcat-init,init" if="tomcat.islocal"> 
    15781669    <property name="tomcat.classpath" refid="local.tomcat.classpath"/> 
    15791670    <property name="tomcat.path" refid="local.tomcat.path"/> 
     
    16221713    <waitfor maxwait="5" maxwaitunit="second"> 
    16231714      <and> 
    1624         <socket server="${tomcat.server}" port="${tomcat.port}"/> 
    1625         <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/index.html"/> 
     1715        <socket server="${tomcat.server}" port="${internal.tomcat.port}"/> 
     1716        <http url="${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}/index.html"/> 
    16261717      </and> 
    16271718    </waitfor> 
     
    16321723    <if><bool><istrue value="${tomcat.isstarted}"/></bool> 
    16331724      <echo>**************************************</echo> 
    1634       <echo>A WEB SERVER IS ALREADY RUNNING ON ${server.protocol}://${tomcat.server}:${tomcat.port}. NOT STARTING.</echo> 
     1725      <echo>A WEB SERVER IS ALREADY RUNNING ON ${server.protocol}://${tomcat.server}:${internal.tomcat.port}. NOT STARTING.</echo> 
    16351726      <echo>**************************************</echo> 
    16361727      <else> 
     
    16411732 
    16421733  <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ --> 
    1643   <target name="force-start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal"> 
     1734  <target name="force-start-tomcat" description="Startup only Tomcat" depends="tomcat-init,init" if="tomcat.islocal"> 
    16441735 
    16451736    <property name="tomcat.classpath" refid="local.tomcat.classpath"/> 
     
    16871778    <waitfor maxwait="5" maxwaitunit="second"> 
    16881779      <and> 
    1689         <socket server="${tomcat.server}" port="${tomcat.port}"/> 
    1690         <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/index.html"/> 
     1780        <socket server="${tomcat.server}" port="${internal.tomcat.port}"/> 
     1781        <http url="${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}/index.html"/> 
    16911782      </and> 
    16921783    </waitfor> 
     
    16951786 
    16961787  <!--ant task http: http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/org/apache/tools/ant/taskdefs/condition/Http.html--> 
    1697   <target name="reconfigure" description="Reconfigure the message router"> 
     1788  <target name="reconfigure" description="Reconfigure the message router" depends="tomcat-init"> 
    16981789    <waitfor maxwait="5" maxwaitunit="second"> 
    1699       <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/> 
     1790      <http url="${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/> 
    17001791    </waitfor> 
    17011792  </target> 
    17021793 
    17031794  <!--Command-line args to Ant: http://www.jguru.com/faq/view.jsp?EID=471794--> 
    1704   <target name="reconfigure-collection" description="Reconfigure the collection"> 
     1795  <target name="reconfigure-collection" description="Reconfigure the collection" depends="tomcat-init"> 
    17051796    <waitfor maxwait="5" maxwaitunit="second"> 
    1706       <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/> 
     1797      <http url="${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/> 
    17071798    </waitfor> 
    17081799  </target> 
     
    17351826       might still be in use for some moments. We test the URL with the http condition since it's likelier to 
    17361827       fail sooner if the server has indeed been stopped. --> 
    1737   <target name="check-tomcat-running"> 
     1828  <target name="check-tomcat-running" depends="tomcat-init"> 
    17381829    <condition property="tomcat.isrunning"> 
    1739       <!--<http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}"/>--> 
    1740       <http url="${server.protocol}://${tomcat.server}:${tomcat.port}"/> 
     1830      <!--<http url="${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}"/>--> 
     1831      <http url="${server.protocol}://${tomcat.server}:${internal.tomcat.port}"/> 
    17411832    </condition> 
    17421833  </target> 
     
    17451836      <target name="verbose-check-tomcat-running"> 
    17461837      <condition property="tomcat.isrunning" value="true" else="false"> 
    1747       <http url="${server.protocol}://${tomcat.server}:${tomcat.port}"/> 
     1838      <http url="${server.protocol}://${tomcat.server}:${internal.tomcat.port}"/> 
    17481839      </condition> 
    17491840      <echo>Tomcat is running: ${tomcat.isrunning}</echo> 
     
    17631854       both stop and start, both of which need to do tomcat checks. Each property can be set only once during  
    17641855       an invocation with ant. So ant restart will need two properties to store each of the tomcat checks --> 
    1765   <target name="check-tomcat-started"> 
     1856  <target name="check-tomcat-started" depends="tomcat-init"> 
    17661857    <condition property="tomcat.isstarted"> 
    1767       <http url="${server.protocol}://${tomcat.server}:${tomcat.port}"/> 
     1858      <http url="${server.protocol}://${tomcat.server}:${internal.tomcat.port}"/> 
    17681859    </condition> 
    17691860  </target> 
     
    17821873     <echo>Waiting for the server to shutdown... (${wait.numchecks} seconds max)</echo> 
    17831874     <waitfor maxwait="${wait.numchecks}" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout"> 
    1784        <not><socket server="${tomcat.server}" port="${tomcat.port}"/></not> 
     1875       <not><socket server="${tomcat.server}" port="${internal.tomcat.port}"/></not> 
    17851876     </waitfor> 
    17861877      
     
    17901881       </bool> 
    17911882       <property name="tomcat.isrunning" value="true"/> 
    1792        <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${tomcat.port} is still busy.</echo> 
     1883       <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${internal.tomcat.port} is still busy.</echo> 
    17931884       <else> 
    17941885     <echo>Tomcat is stopped.</echo> 
     
    20552146  </target> 
    20562147 
    2057   <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site" 
     2148  <target name="soap-deploy-site" depends="tomcat-init,init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site" 
    20582149    description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/> 
    20592150     
     
    20622153      <classpath refid="compile.classpath"/> 
    20632154      <arg value="-l"/> 
    2064       <arg value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/> 
     2155      <arg value="${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}/servlet/AxisServlet"/> 
    20652156      <arg file="${basedir}/resources/soap/deploy.wsdd"/> 
    20662157    </java> 
     
    20682159  </target> 
    20692160   
    2070   <target name="soap-undeploy-site" depends="get-undeploy-service-name" 
     2161  <target name="soap-undeploy-site" depends="tomcat-init,get-undeploy-service-name" 
    20712162    description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."> 
    20722163    <filter token="servicesname" value="${axis.undeploy.servicename}"/> 
     
    20782169      <classpath refid="compile.classpath"/> 
    20792170      <arg value="-l"/> 
    2080       <arg value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/> 
     2171      <arg value="${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}/servlet/AxisServlet"/> 
    20812172      <arg file="${basedir}/resources/soap/undeploy.wsdd"/> 
    20822173    </java> 
     
    20862177  <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server 
    20872178  with the default servicename of localsite--> 
    2088   <target name="deploy-localsite" depends="init"  
     2179  <target name="deploy-localsite" depends="tomcat-init,init"  
    20892180    description="Deploy the SOAP server for localsite. Will start and stop Tomcat."> 
    20902181    <antcall target="force-start-tomcat"/> 
     
    21102201  <target name="get-undeploy-service-name" unless="axis.undeploy.servicename"> 
    21112202    <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy. 
    2112 To find out which web services you've got deployed, point your browser to ${server.protocol}://${tomcat.server}:${tomcat.port}/greenstone3/services  
     2203To find out which web services you've got deployed, point your browser to ${server.protocol}://${tomcat.server}:${internal.tomcat.port}/greenstone3/services  
    21132204Or press Enter for undeploying the default:localsite /&gt;</input> 
    21142205     <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo> 
     
    33973488  </target> 
    33983489     
    3399     <target name="run-collection-tests"> 
     3490    <target name="run-collection-tests" depends="tomcat-init"> 
    34003491        <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool> 
    34013492            <fail>The testing extension is not available. This is required to perform the tests. It can be acquired from SVN by running the command "svn co http://svn.greenstone.org/gs3-extensions/testing/trunk/src testing" in the ext directory of your Greenstone 3 installation. </fail> 
     
    34093500                <java classname="org.junit.runner.JUnitCore" fork="true"> 
    34103501                    <arg value="gstests.TestClass"/> 
    3411                     <jvmarg value="-DSERVERURL=${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet} "/> 
     3502                    <jvmarg value="-DSERVERURL=${server.protocol}://${tomcat.server}:${internal.tomcat.port}${app.path}${server.default.servlet} "/> 
    34123503                    <classpath> 
    34133504                        <fileset dir="${basedir}/ext/testing/lib/java"> 
  • main/trunk/greenstone3/resources/web/global.properties.svn

    r32311 r32334  
    1515 
    1616# tomcat info 
     17server.protocol=@server.protocol@ 
    1718tomcat.server=@tomcat.server@ 
    1819tomcat.port=@tomcat.port@ 
     20tomcat.http.port=@tomcat.http.port@ 
     21tomcat.https.port=@tomcat.https.port@ 
    1922tomcat.context=@greenstone.context@ 
    2023derby.server.port=@derbyserver.port@ 
  • main/trunk/greenstone3/src/java/org/greenstone/server/BaseServerSettings.java

    r29845 r32334  
    5252        catch(Exception e){ 
    5353        logger.error(e); 
     54        System.err.println("Unable to proceed. Port number property " + BaseServer.Property.WEB_PORT + " doesn't exist\nor contains a non-numeric value"); 
     55        exit(-1); 
    5456    }  
    5557 
  • main/trunk/greenstone3/src/java/org/greenstone/util/GlobalProperties.java

    r27869 r32334  
    153153 
    154154            //protocol 
    155             if (properties.getProperty("tomcat.protocol") == null || properties.getProperty("tomcat.protocol").equals("")) 
     155            if (properties.getProperty("server.protocol") == null || properties.getProperty("server.protocol").equals("")) 
    156156            { 
    157157                protocolSpecifier = "http://"; 
     
    159159            else 
    160160            { 
    161                 if (properties.getProperty("tomcat.protocol").endsWith("://")) 
    162                 { 
    163                     protocolSpecifier = properties.getProperty("tomcat.protocol"); 
     161                if (properties.getProperty("server.protocol").endsWith("://")) 
     162                { 
     163                    protocolSpecifier = properties.getProperty("server.protocol"); 
    164164                } 
    165165                else 
    166166                { 
    167                     protocolSpecifier = properties.getProperty("tomcat.protocol") + "://"; 
     167                    protocolSpecifier = properties.getProperty("server.protocol") + "://"; 
    168168                } 
    169169            }