Changeset 24492 for main/trunk


Ignore:
Timestamp:
2011-08-26T16:03:19+12:00 (13 years ago)
Author:
ak19
Message:

The flag --mode=gli has been introduced into LocalLibraryServer.jar, and the prefix used in glisite.cfg.in, while gs2-web-server.bat makes sure these are all passed to Server2, though gs2-web-server.bat no longer parses the cmdline args itself. This commit belongs with the the Server2 of commit r24491, where Server2's main method handles messy commandline arguments of the kind where parameters are split over multiple arguments, which can happen when gs2-webserver.bat calls Server2 now. The logic of dealing with spaces in filepath (and messy parameters) is therefore moved now from gs2-webserver.bat into Server2.java

Location:
main/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java

    r23432 r24492  
    454454   
    455455    static private String getExtraLaunchArguments(LLSSiteConfig site_cfg_file) {
    456     String args = " " + site_cfg_file.getSiteConfigFilename();
     456    String args = " " + LLSSiteConfig.GLIMODE + " " + site_cfg_file.getSiteConfigFilename();
    457457
    458458    if(isPersistentServer) {
     
    679679    static final private String URL = "url";
    680680    static final private String COLLECTHOME = "collecthome";
     681    static final private String GLIMODE = "--mode=gli";
    681682   
    682683    static final public String URL_PENDING = "URL_pending";
  • main/trunk/greenstone2/glisite.cfg.in

    r24208 r24492  
    66keepport=0
    77externalaccess=0
    8 autoenter=1
     8gli.autoenter=1
    99browser=3
    10 start_browser=0
     10gli.start_browser=0
    1111address_resolution_method=2
    1212hostIP=
  • main/trunk/greenstone2/gs2-web-server.bat

    r23987 r24492  
    190190
    191191:: GLI launches gs2-server.bat with:
    192 :: cmd /c start "window" "c:\path to\gs2-server.bat" --config=c:\path to\glisite.cfg [--quit=portnum]
     192:: cmd /c start "window" "c:\path to\gs2-web-server.bat" --config=c:\path to\glisite.cfg --quit=portnum --mode=gli
     193:: where the --options are generally optional, but always used for GLI.
    193194:: The configfile param could contain spaces, in which case its space-separated parts spread over
    194 :: multiple parameters . Need to handle things the following way, since using quotes to embed the
    195 :: parameters breaks the start command, see http://ss64.com/nt/start.html
    196 :: This script is launched by the start cmd as:
    197 :: "c:\path to\gs2-server.bat" --config=c:\path to\config.cfg [--quit=portnum].
    198 :: But if the parameter  following --config=<some string> doesn't start with a double hyphen, we
    199 :: assume it to be part of the config parameter, as the configfile path may have contained spaces.
    200 
    201 :: Store all parameters together in config file var: we may or may not have a portnumber
    202 :: Get everything after the "--quitport=", if anything, and store it in port var.  If no port, nothing to do.
    203 set conf=%*
    204 if "%conf%" == "" goto :runit
    205 
    206 set port=%conf:*--quitport=%
    207 if "%conf%" == "%port%" (
    208 set port=
    209 goto :runit
    210 ) else (
    211 set port=%port:~1%
    212 )
    213 
    214 :: Because we got here, need to adjust conf by removing " --quitport=" from it and prefixing this to port
    215 call set conf=%%conf:%port%=%%
    216 set conf=%conf:~0,-12%
    217 set port=--quitport=%port%
    218 
    219 :: Remove trailing spaces from conf and port
    220 :: (We'll put the all-important quotes around conf and port when the actual java cmd is launched)
    221 set tmp=%conf%
    222 call :trim %tmp%
    223 set conf=%tmp%
    224 set tmp=%port%
    225 call :trim %port%
    226 set port=%tmp%
    227 set tmp=
    228 
    229 goto :runit
    230 
    231 ::  http://www.computing.net/answers/programming/dos-batch-remove-trailing-space/9270.html
    232 :trim
    233 set tmp=%*
    234 goto :eof
     195:: multiple parameters. In the past, we used to handle this problem here.
     196:: At present we pass all the arguments as-is to the Server.jar program and let it handle the parameters.
     197:: E.g. gs2-web-server.bat --config=C:\pinky was\here at greenstone2\glisite.cfg --mode=gli --quitport=50100
     198:: or gs2-web-server.bat --quitport=50100 --config=C:\pinky was\here at greenstone2\glisite.cfg --mode=gli
     199:: Note the (lack of) use of quotes!
     200
    235201
    236202:runit
     
    242208
    243209::echo port: %port%& echo conf: %conf%& echo.& echo.
    244 :: "%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" %*
    245 "%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" "%conf%" "%port%"
    246 
    247 
    248 :: The 1st argument to gs2-server.bat (if any) would be --config, the 2nd is the config filename.
    249 :: Both are stored in %conf% now. If the config file is glisite.cfg, then this script was launched through
    250 :: GLI and would have opened a DOS console. Need to exit from this script then to close the console.
    251 :: Remove --config=prefix and do a case insensitive comparison, since filepaths can have uppercase chars
    252 if "%conf%" == "" goto exit
    253 if /i "%conf:~9%" == "%GSDLHOME%\glisite.cfg" goto quitcmd
    254 goto exit
     210:: Do not remove the quotes around %* !!! It's what helps Server2.jar deal with spaces in configfile path
     211"%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" "%*"
     212
     213
     214:: All params are stored in %* now. This batch script can be called from the commandline or from GLI
     215:: If the --mode(=gli) flag was passed in as parameter, then this script was launched through GLI
     216:: and would have opened a DOS console. Need to then exit from this script to close the console.
     217set allparams=%*
     218:: And if there were absolutely no params to gs2-web-server.bat, it's not called from GLI either
     219if "%allparams%" == "" goto exit
     220set glimode=%allparams:--mode=%
     221:: if one of the parameters was --mode(=gli), we close the console
     222if /i "%allparams%" == "%glimode%" (
     223    goto exit
     224) else (
     225    goto quitcmd
     226)
    255227
    256228:: Exit the batch script (close the console)
Note: See TracChangeset for help on using the changeset viewer.