Changeset 29361
- Timestamp:
- 2014-10-10T16:59:53+13:00 (10 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r29356 r29361 744 744 p = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "ant stop -f \"" + Configuration.gsdl3_src_path + File.separator + "build.xml\""}); 745 745 } 746 if(p != null && p.waitFor() == 0) { 746 // doing a p.waitFor() without processing the Process' IOstreams causes blocking with Java 6 747 // (i.e. when JRE 6 included with GS binaries). However, p.waitFor() with Java 7 is fine. 748 /*if(p != null && p.waitFor() == 0) { 747 749 DebugStream.println("********** SUCCESSFULLY stopped THE GS3 SERVER ON EXIT"); 748 750 } … … 750 752 System.err.println("********** FAILED TO SUCCESSFULLY stop THE GS3 SERVER ON EXIT"); 751 753 //throw new Exception ("Failed to successfully stop the GS3 server on exit."); 752 } 754 }*/ 753 755 } catch(Exception e) { 754 756 System.err.println("Exception when trying to stop the tomcat web server: " + e); -
main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r29222 r29361 1755 1755 GS3ServerThread thread = new GS3ServerThread(Configuration.gsdl3_src_path, "restart"); 1756 1756 thread.start(); 1757 1758 // sleep before returning and doing the configGS3Server: give the GS3 server time to restart 1759 try { 1760 Thread.sleep(5000); 1761 } catch(Exception e) { 1762 e.printStackTrace(); 1763 } 1757 1758 // Give the GS3 server time to restart: 1759 // the GS3ServerThread above waits for the process to terminate. ant restart target calls the start-tomcat ant target 1760 // and that takes waits 5 seconds and polls to see if a GS3 server index page has loaded. So no need to sleep here 1764 1761 1765 1762 } … … 2038 2035 return true; 2039 2036 } 2040 2041 if(CollectionManager.isSolrCollection()) {2042 // No installCollection() for GS3 solr collection: activate will take care of that2043 DebugStream.println("Solr collection build complete: building already moved to index by activate.pl.");2044 2045 // Finished building,2046 // For now, for a GS3 solr collection, we'd have stopped the GS3 server before building2047 // and will now need to restart it.2048 GS3ServerThread thread = new GS3ServerThread(Configuration.gsdl3_src_path, "restart");2049 thread.start();2050 2051 return true;2052 }2053 2054 2037 2055 2038 DebugStream.println("Build complete. Moving files."); -
main/trunk/gli/src/org/greenstone/gatherer/util/GS3ServerThread.java
r29356 r29361 78 78 79 79 if (p != null) { 80 int result = p.waitFor(); 81 if(result != 0) { 80 // in order for the process.waitFor() method to work with Java 6 (JRE 6 is included in GS binaries) 81 // need to make sure the IOstreams of the process are not blocked. For Java 7, this is not necessary 82 // and a waitFor() is sufficient. But with Java 6, the waitFor() causes the server to finally start 83 // after the user has quit GLI. 84 85 // Process takes no input, but we will still catch this iostream too 86 // And we'll catch the error and output streams to prevent them from blocking during waitFor() 87 // (For normal input and output stream handling using the Gobblers, see FormatConversionDialog.java) 88 OutputStreamGobbler inputGobbler = new OutputStreamGobbler(p.getOutputStream(), null); 89 InputStreamGobbler errorGobbler = new InputStreamGobbler(p.getErrorStream(), true); 90 InputStreamGobbler outputGobbler = new InputStreamGobbler(p.getInputStream()); 91 92 errorGobbler.start(); 93 outputGobbler.start(); 94 inputGobbler.start(); 95 96 // the important part: wait for the process (ant stop or start or re-start to terminate) 97 int result = p.waitFor(); 98 if(result != 0) { 82 99 System.err.println("**** Failed to successfully " + _ant_command + " the GS3 server."); 83 } 100 } 101 102 outputGobbler.join(); 103 errorGobbler.join(); 104 inputGobbler.join(); 84 105 } else { 85 106 System.err.println("**** Could not start the Process to " + _ant_command + " the GS3 server."); -
main/trunk/gli/src/org/greenstone/gatherer/util/OutputStreamGobbler.java
r29031 r29361 51 51 public void run() 52 52 { 53 54 if (inputstr == null) { 55 return; 56 } 57 53 58 BufferedWriter osw = null; 54 59 try {
Note:
See TracChangeset
for help on using the changeset viewer.