Changeset 22661
- Timestamp:
- 2010-08-17T18:43:08+12:00 (14 years ago)
- Location:
- main/trunk/gli
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/classes/dictionary.properties
r22605 r22661 632 632 General.Outstanding_Processes_Title:Waiting To Exit 633 633 General.Pure_Cancel_Tooltip:Abort this action (no changes will be made) 634 General.Reconfigure:Reconfigure your web server manually 634 635 General.Review_Output:Please review output below: 635 636 General.Redo:Redo … … 1011 1012 Server.QuitTimeOut:The greenstone local library has not responded to the\nautomatic close command for {0} seconds. Do you\nwish to wait for another {0} seconds? 1012 1013 Server.StartUpTimeOut:The greenstone local library has not responded to the\nstart command for {0} seconds. Do you\nwish to wait for another {0} seconds? 1014 Server.Reconfigure:You just changed collecthome.\nAs GLI didn't start your webserver, it can't reconfigure this automatically.\nPlease reconfigure your server manually to work with the change to collecthome. 1013 1015 # 1014 1016 #***** Sources ***** -
main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r22605 r22661 829 829 830 830 // non-destructive update of gsdl(3)site.cfg (comments preserved) 831 Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", Gatherer.getCollectDirectoryPath()); 831 String collectDir = Gatherer.getCollectDirectoryPath(); 832 collectDir = collectDir.substring(0, collectDir.length()-1); // remove file separator at end 833 Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", collectDir); 834 835 if(!Gatherer.GS3 && Gatherer.isLocalLibrary) { 836 // for Images in the collection to work, the apache web server 837 // configuration's COLLECTHOME should be updated on collectdir change. 838 // Does nothing for server.exe at the moment 839 840 LocalLibraryServer.reconfigure(); 841 } 832 842 } 833 843 -
main/trunk/gli/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java
r22608 r22661 58 58 // The socket port number that we will use to communicate the termination 59 59 static private int port; 60 static private Socket clientSocket = null; 61 static private Writer clientSocketWriter = null; 60 62 61 63 // The server is persistent if it does not have to reload all the values … … 125 127 126 128 try { 127 Socket clientSocket = new Socket("localhost", port); 128 Writer writer = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream())); 129 writer.write(message); 130 writer.close(); 131 writer = null; 129 if(clientSocket == null) { 130 clientSocket = new Socket("localhost", port); 131 } 132 if(clientSocketWriter == null) { 133 clientSocketWriter = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream())); 134 } 135 clientSocketWriter.write(message); 136 clientSocketWriter.flush(); 137 132 138 } catch (Exception e) { 133 139 System.err.println("An exception occurred when trying to send the message: " + message … … 286 292 } 287 293 294 /** Call this when the collect directory has changed. Only works when using 295 * the web server launched by GLI. */ 296 static public void reconfigure() { 297 if(isPersistentServer) { 298 System.err.println("***** Reconfigure is not yet implemented for server.exe"); 299 return; 300 } 301 302 // can't control the GSI/server if it was launched independent of GLI 303 if(llssite_cfg_file.isIndependentGSI()) { 304 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Server.Reconfigure"), Dictionary.get("General.Reconfigure"), JOptionPane.INFORMATION_MESSAGE); 305 return; 306 } 307 308 // someone may have closed the web server 309 if(checkServerRunning()) { // need a server to be running in order for us to send a reconfigure message to it 310 return; // it has reconfigured and restarted the server 311 } 312 313 // If it was already running, tell the server a reconfigure is required on next restart 314 // and then restart 315 if(running && sendMessageToServer("RECONFIGURE\n")) { 316 // restart 317 if(running) { 318 running = false; 319 320 if(sendMessageToServer("RESTART\n")) { //if(sendMessageToServer("RECONFIGURE\n")) { 321 // wait for the server to update the URL in the gli config file 322 llssite_cfg_file.setLastModified(); 323 324 int attempt_count = 0; 325 while (!llssite_cfg_file.isModified()) { 326 new OneSecondWait(); // Wait one second (give or take) 327 attempt_count++; 328 329 // After waiting for the specified time, ask the user whether they want to wait for that long again 330 if (attempt_count == WAITING_TIME) { 331 break; // can't be waiting forever, we'll be waiting again below 332 } 333 } 334 335 try { 336 testServerRunning(); // will set running = true when the server is up and running successfully 337 } catch (IOException bad_url_connection) { 338 try { 339 // If this fails then we try changing the url to be localhost 340 Configuration.library_url = new URL(llssite_cfg_file.getLocalHostURL()); 341 DebugStream.println("Try connecting to server on local host: '" + Configuration.library_url + "'"); 342 URLConnection connection = Configuration.library_url.openConnection(); 343 connection.getContent(); 344 running = true; 345 346 } catch (IOException worse_url_connection) { 347 DebugStream.println("Can't connect to server on either address."); 348 Configuration.library_url = null; 349 running = false; 350 } 351 } 352 } 353 } 354 } else { 355 System.err.println("GLI was unable to send a reconfigure request to the local library server." 356 + "\nPlease reconfigure and restart the local Greenstone server manually."); 357 } 358 } 359 288 360 289 361 static public void stop() … … 303 375 config(QUIT_COMMAND); 304 376 } else { 305 if(sendMessageToServer("QUIT")) { 377 boolean success = sendMessageToServer("QUIT\n"); 378 try { 379 if(clientSocketWriter != null) { 380 clientSocketWriter.close(); 381 clientSocketWriter = null; 382 } 383 clientSocket = null; 384 } catch(Exception e) { 385 System.err.println("An exception occurred when trying to close the socket" 386 + "\nto the LocalLibraryServer.\n" + e); 387 } 388 if(success) { 306 389 Gatherer.terminateApplication(ID); 307 390 } else { … … 446 529 } 447 530 448 static public void checkServerRunning() { 449 if (!running) return; // don't worry about it if it's not supposed to be running 531 /** @returns true if it had to restart the server. Returns false if it didn't restart it. */ 532 static public boolean checkServerRunning() { 533 boolean serverRestarted = false; 534 535 if (!running) return false; // don't worry about it if it's not supposed to be running 450 536 llssite_cfg_file.load(true); // don't force reload, load only if modified 451 537 … … 454 540 if(url.equals(LLSSiteConfig.URL_PENDING)) { 455 541 running = false; 456 return ;542 return false; 457 543 } 458 544 … … 480 566 running = true; 481 567 } 482 return ; // don't need to launch the server, one has been independently launched568 return false; // don't need to launch the server, one has been independently launched 483 569 } else { 484 570 // else we try using the glisite configfile 485 571 llssite_cfg_file.useGLISiteCfg(local_library_server_file); 486 572 //llssite_cfg_file.set(); 573 574 // since we're going to restart the server, make sure to reset all 575 // the client socket and its writer (for communicating with the web server) 576 // will only be reinstantiated if they are first nulled 577 if(clientSocket != null) { 578 clientSocket = null; 579 } 580 if(clientSocketWriter != null) { 581 try{ 582 clientSocketWriter.close(); 583 clientSocketWriter = null; 584 } catch(Exception e) { 585 System.err.println("Unable to close the client socket outputstream."); 586 } finally { 587 clientSocketWriter = null; 588 } 589 } 487 590 488 591 // Spawn local library server process … … 496 599 try { 497 600 testServerRunning(); // don't return until the webserver is up and running 601 serverRestarted = true; 498 602 } catch (IOException bad_url_connection) { 499 603 DebugStream.println("Can't connect to server on address " + Configuration.library_url); … … 502 606 } 503 607 } 608 return serverRestarted; 504 609 } 505 610 … … 645 750 url.append((String)get(PORTNUMBER)); 646 751 String enterlib = (String)get(ENTERLIB); 647 if( enterlib == null || enterlib.length() == 0) {752 if(!isPersistentServer || enterlib == null || enterlib.length() == 0) { 648 753 // Use the default /gsdl and hope for the best. 649 754 url.append(SEPARATOR); … … 702 807 debug("Found Local Library Address: " + url); 703 808 return url; 809 } 810 811 public void setLastModified() { 812 if(isModified()) { 813 lastModified = configFile.lastModified(); 814 } 704 815 } 705 816
Note:
See TracChangeset
for help on using the changeset viewer.