Changeset 20480 for gli


Ignore:
Timestamp:
2009-09-02T13:45:08+12:00 (15 years ago)
Author:
ak19
Message:

Changes made to incorporate the Local Apache Library Server on Windows. Needs to be retested on Linux to make sure things still work there.

File:
1 edited

Legend:

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

    r19758 r20480  
    6363    // but the Apache webserver is not persistent by default.
    6464    // Change the initialisation of this value depending on whether fastcgi is
    65     // on. At the moment, this does not apply to the Linux' local library server.
    66     static private boolean isPersistentServer = Utility.isWindows();
     65    // on. At the moment, this does not apply to the Apache local library server.
     66    static private boolean isPersistentServer = false;
    6767
    6868    static public void addCollection(String collection_name)
     
    114114    }
    115115
    116     // Used to send messages to the local server on Linux
     116    // Used to send messages to the local library server wrapper to the Apache web server (server.jar)
    117117    static private boolean sendMessageToServer(String message) {
    118     if(Utility.isWindows()) {
     118    if(isPersistentServer) {
    119119        return false;
    120120    }
     
    164164    static public boolean start(String gsdl_path, String local_library_server_file_path)
    165165    {
    166     // In the case of the Local Library Server on Linux, we need to do an extra test:
    167     // If GS2 was not configured with --enable-apache-httpd, then there is no apache webserver folder,
    168     // even though the gs2-server.sh file would still be there. That means if the folder is absent
    169     // we still have no local library server.
    170     if(!Utility.isWindows()) {
    171         File localLinuxServerFolder = new File(gsdl_path, "apache-httpd");
    172         if (!localLinuxServerFolder.exists() && !localLinuxServerFolder.isDirectory()) {
    173         DebugStream.println("The web server does not exist at "
    174                     + localLinuxServerFolder.getAbsolutePath() + "\nNo local library at all. Trying web library");
    175         return false;
    176         }
    177     }
    178 
    179166    // Check the local library server file (server.exe or gs2-server.sh) exists
    180167    if(local_library_server_file_path == null) {
    181168        return false;
    182169    }
    183     local_library_server_file = new File(local_library_server_file_path);   
    184     if (!local_library_server_file.exists()) {
     170    local_library_server_file = new File(local_library_server_file_path);
     171    if (local_library_server_file.exists()) {
     172        if(local_library_server_file.getName().equals("server.exe")) {
     173        isPersistentServer = true;
     174        } // else it may be gs2-server.bat
     175    }
     176    else { // local_library_server_file does not exist
    185177        DebugStream.println("No local library at given file path.");
    186    
    187         String defaultServerFilename = Utility.isWindows() ? "server.exe" : "gs2-server.sh";
    188         local_library_server_file = new File(gsdl_path + defaultServerFilename);
    189         if (!local_library_server_file.exists()) {
    190         DebugStream.println("No local library at all.");
     178
     179        if(Utility.isWindows()) { // test for server.exe and gs2-server.bat
     180        local_library_server_file = new File(gsdl_path + "server.exe");
     181        if (local_library_server_file.exists()) {
     182            isPersistentServer = true;
     183        } else {
     184            local_library_server_file = new File(gsdl_path + "gs2-server.bat");
     185            if (!local_library_server_file.exists()) {
     186            DebugStream.println("No local library at all.");
     187            return false;
     188            }
     189        }       
     190        } else { // linux
     191        local_library_server_file = new File(gsdl_path + "gs2-server.sh");
     192        if (!local_library_server_file.exists()) {
     193            DebugStream.println("No local library at all.");
     194            return false;
     195        }
     196        }
     197    }   
     198
     199    if(!isPersistentServer) {
     200        // In the case of the Local Library Server on Linux or on Win where there's no server.exe, do an extra test:
     201        // If GS2 was not configured with --enable-apache-httpd, then there is no apache webserver folder,
     202        // even though the gs2-server.sh file would still be there. That means if the folder is absent
     203        // we still have no local library server.
     204
     205        File localServerFolder = new File(gsdl_path, "apache-httpd");
     206        if (!localServerFolder.exists() && !localServerFolder.isDirectory()) {
     207        DebugStream.println("The web server does not exist at "
     208                + localServerFolder.getAbsolutePath() + "\nNo local library at all. Trying web library");
    191209        return false;
    192         }
    193     }   
     210        } // else apache-httpd folder exists
     211    }
    194212
    195213    llssite_cfg_file = new LLSSiteConfig(local_library_server_file);
     
    214232    // Spawn local library server process
    215233    String local_library_server_command = local_library_server_file.getAbsolutePath() + getExtraLaunchArguments(llssite_cfg_file);
     234    if(Utility.isWindows()) {
     235        local_library_server_command = "cmd.exe /c start \"GSI\" " + local_library_server_command;
     236    }
    216237
    217238    // Check if the server is already running
     
    242263    // Wait until program has started
    243264    try {
    244         testServerRunning(); // will set running = true when the server is up and running successfully     
     265        //System.err.println("**** testing server...");
     266        testServerRunning(); // will set running = true when the server is up and running successfully
     267        //System.err.println("**** Is server running: " + running);
    245268    } catch (IOException bad_url_connection) {
    246269        try {
     
    324347    String args = " " + site_cfg_file.getSiteConfigFilename();
    325348
    326     if(Utility.isWindows()) {
     349    if(isPersistentServer) {
    327350        return args;
    328351    }
    329352   
    330     // Else, when running the Local Library Server on Linux, need to provide a port argument
     353    // Else, when running the Local Apache Library Server on Linux/Win, need to provide a port argument
    331354    try {
    332355        PortFinder portFinder = new PortFinder(50100, 100);
     
    349372    while (llssite_cfg_file.getURL() == null) {
    350373        new OneSecondWait();  // Wait one second (give or take)
     374        //System.err.println("**** One Second Wait");
    351375        llssite_cfg_file.load(false);
    352376        attempt_count++;
     
    388412     * in an independently launched GSI (one not launched by GLI). */
    389413    static public boolean isURLPending() {
    390     /*if(Configuration.library_url != null) {
    391         System.err.println("**** Configuration.library_url: " + Configuration.library_url );
    392         return false; // don't need to do anything as we already have the url
    393         }*/
     414    //if(Configuration.library_url != null) {
     415    //System.err.println("**** Configuration.library_url: " + Configuration.library_url );
     416    //return false; // don't need to do anything as we already have the url
     417    //}
    394418
    395419    llssite_cfg_file.load(true); // don't force reload, load only if modified
     
    462486       
    463487        // Spawn local library server process
     488        running = false;
    464489        String local_library_server_command = local_library_server_file.getAbsolutePath() + getExtraLaunchArguments(llssite_cfg_file);
    465         running = false;
     490        if(Utility.isWindows()) {
     491            local_library_server_command = "cmd.exe /c start \"GSI\" " + local_library_server_command;
     492        }
    466493        Gatherer.spawnApplication(local_library_server_command, ID);
    467494        try {
     
    648675        }
    649676
    650         if(!Utility.isWindows()) {
     677        if(!isPersistentServer) {
    651678        return url;
    652679        }
Note: See TracChangeset for help on using the changeset viewer.