Changeset 31578
- Timestamp:
- 2017-04-06T15:24:43+12:00 (7 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/CollectionConstructor.java
r31572 r31578 25 25 protected EventListenerList listeners = null; 26 26 /** A flag used to determine if this process has been asked to cancel. */ 27 protected boolean cancel = false; 27 protected boolean cancel = false; // Not really used (in any way that works) 28 28 /** Stores the name of the manifest file (if one is needed) */ 29 29 protected String manifest_file = null; 30 31 30 /** The URL params constructed as a query string, representing the CGI QUERY_STRING to the process */ 31 protected String query_string = null; 32 32 33 33 public CollectionConstructor(String name) -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
r31574 r31578 36 36 public static final int BUILD = 2; 37 37 public static final int ACTIVATE = 3; 38 38 public static final int MODIFY_METADATA_SERVER = 4; 39 39 40 40 /** … … 49 49 /** the path environment variable */ 50 50 protected String path = null; 51 51 52 52 53 public GS2PerlConstructor(String name) … … 409 410 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str)); 410 411 411 412 logger.info("### Running command = " + command_str); 412 //logger.info("### Running command = " + command_str); 413 413 414 414 // This is where we create and run our perl process safely … … 450 450 // std in of java, as before. 451 451 452 logger.info("**** BEFORE runProcess.");453 452 perlProcess.runProcess(); 454 logger.info("**** AFTER runProcess:");455 453 456 454 // The original runPerlCommand() code had an ineffective check for whether the cmd had been cancelled … … 545 543 } 546 544 547 logger.info("### old runPerlCmd, command = " + command_str);545 // logger.info("### old runPerlCmd, command = " + command_str); 548 546 549 547 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str)); -
main/trunk/greenstone3/src/java/org/greenstone/util/SafeProcess.java
r31574 r31578 97 97 //***************** Copied from gli's gui/FormatConversionDialog.java *************// 98 98 public void runProcess() { 99 99 100 Process prcs = null; 100 101 SafeProcess.OutputStreamGobbler inputGobbler = null; … … 103 104 104 105 try { 105 106 106 Runtime rt = Runtime.getRuntime(); 107 107 108 109 108 // http://stackoverflow.com/questions/5283444/convert-array-of-strings-into-a-string-in-java 110 logger.info("Running process: " + Arrays.toString(command_args));109 //logger.info("Running process: " + Arrays.toString(command_args)); 111 110 112 111 if(this.envp == null) { … … 115 114 116 115 if(this.dir == null) { 117 logger.info("\twith: " + Arrays.toString(this.envp));116 //logger.info("\twith: " + Arrays.toString(this.envp)); 118 117 prcs = rt.exec(this.command_args, this.envp); 119 118 } else { 120 logger.info("\tfrom directory: " + this.dir);121 logger.info("\twith: " + Arrays.toString(this.envp));119 //logger.info("\tfrom directory: " + this.dir); 120 //logger.info("\twith: " + Arrays.toString(this.envp)); 122 121 prcs = rt.exec(this.command_args, this.envp, this.dir); 123 122 } 124 123 } 125 124 126 logger.info("### Before creating ProcessInGobbler");127 128 129 125 // send inputStr to process. The following constructor can handle inputStr being null 130 126 inputGobbler = // WriterToProcessInputStream 131 127 new SafeProcess.OutputStreamGobbler(prcs.getOutputStream(), this.inputStr); 132 128 133 logger.info("### Before creating ProcessErrGobbler");134 135 129 // monitor for any error messages 136 130 errorGobbler // ReaderFromProcessOutputStream 137 131 = new SafeProcess.InputStreamGobbler(prcs.getErrorStream(), splitStdOutputNewLines); 138 132 139 logger.info("### Before creating ProcessOutGobbler");140 141 133 // monitor for the expected std output line(s) 142 134 outputGobbler 143 135 = new SafeProcess.InputStreamGobbler(prcs.getInputStream(), splitStdErrorNewLines); 144 145 logger.info("### Before setting handlers on ProcessGobblers");146 136 147 137 // register line by line handlers, if any were set, for the process stderr and stdout streams … … 156 146 } 157 147 158 logger.info("### Before streamgobblers.start()");159 160 148 // kick off the stream gobblers 161 149 inputGobbler.start(); 162 150 errorGobbler.start(); 163 151 outputGobbler.start(); 164 165 logger.info("### After streamgobblers.start() - before waitFor");166 152 167 153 // any error??? 168 154 this.exitValue = prcs.waitFor(); // can throw an InterruptedException if process did not terminate 169 logger.info("ExitValue: " + exitValue);170 171 logger.info("### Before streamgobblers.join()");172 173 155 // From the comments of 174 156 // http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html?page=2 … … 180 162 inputGobbler.join(); 181 163 182 logger.info("### After streamgobblers.join()");183 184 164 // set the variables the code that created a SafeProcess object may want to inspect 185 165 this.outputStr = outputGobbler.getOutput(); 186 166 this.errorStr = errorGobbler.getOutput(); 187 167 188 // the calling code should handle errorStr, not us, so can leave out the following code189 /*190 if(!this.errorStr.equals("")) {191 logger.info("*** Process errorstream: \n" + this.errorStr + "\n****");192 //System.err.println("*** Process errorstream: \n" + this.errorStr + "\n****");193 }194 */195 196 168 // Since we didn't have an exception, process should have terminated now (waitFor blocks until then) 197 169 // Set process to null so we don't forcibly terminate it below with process.destroy()
Note:
See TracChangeset
for help on using the changeset viewer.