Ignore:
Timestamp:
2009-04-01T19:31:09+13:00 (15 years ago)
Author:
ak19
Message:

Updated Server files for Linux GS2 Local Library Server to work the same way as the Windows GS2 LLS. Basically the major difference is that build.properties is no longer used but glisite.cfg or llssite.cfg depending on whether or not gs2-server.sh is launched from gli. There are a few additional changes required for this to keep it consistent with the way the Windows GS2 LLS works: storing the preview URL in glisite.cfg/llssite.cfg while the server is running and removing it when the server has stopped, Server2.java's main method taking the configfile as an additional parameter (and corresponding adjustments in the gsicontrol.sh script of GS2).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/server/BaseServer.java

    r18770 r18868  
    2424    static protected final int SERVER_START_FAILED = 1;
    2525    static protected final int BROWSER_LAUNCHED = 2;
    26     static protected final int BROWSER_LAUNCH_FAILED = 3;
     26    static protected final int BROWSER_LAUNCH_FAILED = 3;
     27    static protected final int START_SERVER = 4;
    2728 
    28     static protected Properties build_properties;
     29    static protected Properties config_properties;
    2930    static protected Logger logger_;
    3031
    31     static public File build_properties_file;
     32    static public File config_properties_file;
    3233    static public Dictionary dictionary;
    3334    static public BaseProperty Property;
     
    3738    protected String gsdl_home;
    3839    protected String logs_folder;
     40    protected boolean start_browser;
     41
    3942    protected BaseServerControl server_control_;   
    4043   
    41     protected BaseServer(String gsdl_home, String lang, String build_properties_path, String logs)
     44    protected BaseServer(String gsdl_home, String lang, String config_properties_path, String logs)
    4245    {
    4346    this.gsdl_home = gsdl_home;
     
    4952    logger_ = Logger.getLogger(BaseServer.class.getName());
    5053
    51     build_properties_file = new File(build_properties_path);
    52 
    53     if (!build_properties_file.exists()) {
    54         logger_.fatal("Can't find build.properties file "+build_properties_path);
     54    config_properties_file = new File(config_properties_path);
     55   
     56    if (!config_properties_file.exists()) {
     57        logger_.fatal("Can't find configuration file "+config_properties_path);
    5558        System.exit(1);
    5659    }
    5760   
    58     build_properties = new Properties();
    59     reloadBuildProperties();
    60    
     61    config_properties = new Properties();
     62    reloadConfigProperties();
     63
    6164    dictionary = new Dictionary("server", lang, this.getClass().getClassLoader());
    6265
     
    6568    public void autoStart()
    6669    {
    67     String auto_start = build_properties.getProperty(BaseServer.Property.AUTOSTART);
    68     if (auto_start != null && auto_start.equals("true")) {
    69         restart();
    70     }
    71     else{
    72         start();
    73     } 
    74    
     70    String auto_start = config_properties.getProperty(BaseServer.Property.AUTOSTART, "true");
     71
     72    if (auto_start.equals("true") || auto_start.equals("1")) {
     73        String start_browser = config_properties.getProperty(BaseServer.Property.START_BROWSER, "true");
     74
     75        if (start_browser.equals("true") || start_browser.equals("1")) {
     76        restart();
     77        }
     78        else{
     79        start();
     80        } 
     81    } else {
     82        reload(); // browser URL or other important properties may not yet be initialised
     83        server_state_ = START_SERVER;
     84        server_control_.updateControl();
     85    }
    7586    }
    7687
     
    91102    public abstract String getBrowserURL();
    92103    public abstract void reload(); // reload properties, since they may have changed
     104    protected void preStop() {}
    93105
    94106    public void reconfigRequired()
     
    118130    }
    119131    else{
    120         recordSuccess(CONFIGURE_CMD); 
     132        recordSuccess(CONFIGURE_CMD);
    121133    }
    122134   
     
    162174    String url = getBrowserURL();
    163175    //recordError("**** browserURL: " + url);
    164     BrowserLauncher launcher = new BrowserLauncher(build_properties.getProperty(BaseServer.Property.BROWSER_PATH),url);
     176    BrowserLauncher launcher = new BrowserLauncher(config_properties.getProperty(BaseServer.Property.BROWSER_PATH, ""),url);
    165177        logger_.info(message);
    166178
     
    203215
    204216    public void stop(boolean silent) {
     217    preStop();
    205218    if(!silent) {
    206219        server_control_.displayMessage(dictionary.get("ServerControl.Stopping"));
     
    217230    }
    218231   
    219     public  void reloadBuildProperties() {
     232    public  void reloadConfigProperties() {
    220233    try {
    221         FileInputStream in = new FileInputStream(build_properties_file);
     234        FileInputStream in = new FileInputStream(config_properties_file);
    222235
    223236        if (in != null) {
    224         logger_.info("loading build properties");
    225         build_properties.load(in);
     237        logger_.info("loading configuration properties: " + config_properties_file);
     238        config_properties.load(in);
    226239        in.close();
    227240        } else {
    228         logger_.error("Couldn't load build properties!");
     241        logger_.error("Couldn't load configuration properties from " + config_properties_file + "!");
    229242        }
    230243    } catch (Exception e) {
    231         logger_.error("Exception trying to reload build.properties: "+e);
     244        logger_.error("Exception trying to reload configuration properties " +config_properties_file + ": " +e);
    232245    }
    233246   
Note: See TracChangeset for help on using the changeset viewer.