Changeset 20480
- Timestamp:
- 2009-09-02T13:45:08+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java
r19758 r20480 63 63 // but the Apache webserver is not persistent by default. 64 64 // 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; 67 67 68 68 static public void addCollection(String collection_name) … … 114 114 } 115 115 116 // Used to send messages to the local server on Linux116 // Used to send messages to the local library server wrapper to the Apache web server (server.jar) 117 117 static private boolean sendMessageToServer(String message) { 118 if( Utility.isWindows()) {118 if(isPersistentServer) { 119 119 return false; 120 120 } … … 164 164 static public boolean start(String gsdl_path, String local_library_server_file_path) 165 165 { 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 absent169 // 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 179 166 // Check the local library server file (server.exe or gs2-server.sh) exists 180 167 if(local_library_server_file_path == null) { 181 168 return false; 182 169 } 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 185 177 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"); 191 209 return false; 192 } 193 } 210 } // else apache-httpd folder exists 211 } 194 212 195 213 llssite_cfg_file = new LLSSiteConfig(local_library_server_file); … … 214 232 // Spawn local library server process 215 233 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 } 216 237 217 238 // Check if the server is already running … … 242 263 // Wait until program has started 243 264 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); 245 268 } catch (IOException bad_url_connection) { 246 269 try { … … 324 347 String args = " " + site_cfg_file.getSiteConfigFilename(); 325 348 326 if( Utility.isWindows()) {349 if(isPersistentServer) { 327 350 return args; 328 351 } 329 352 330 // Else, when running the Local Library Server on Linux, need to provide a port argument353 // Else, when running the Local Apache Library Server on Linux/Win, need to provide a port argument 331 354 try { 332 355 PortFinder portFinder = new PortFinder(50100, 100); … … 349 372 while (llssite_cfg_file.getURL() == null) { 350 373 new OneSecondWait(); // Wait one second (give or take) 374 //System.err.println("**** One Second Wait"); 351 375 llssite_cfg_file.load(false); 352 376 attempt_count++; … … 388 412 * in an independently launched GSI (one not launched by GLI). */ 389 413 static public boolean isURLPending() { 390 / *if(Configuration.library_url != null) {391 392 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 //} 394 418 395 419 llssite_cfg_file.load(true); // don't force reload, load only if modified … … 462 486 463 487 // Spawn local library server process 488 running = false; 464 489 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 } 466 493 Gatherer.spawnApplication(local_library_server_command, ID); 467 494 try { … … 648 675 } 649 676 650 if(! Utility.isWindows()) {677 if(!isPersistentServer) { 651 678 return url; 652 679 }
Note:
See TracChangeset
for help on using the changeset viewer.