Changeset 31592
- Timestamp:
- 2017-04-07T18:20:11+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/GS2PerlConstructor.java
r31591 r31592 335 335 // http://www.cgi101.com/class/ch3/text.html 336 336 // setenv QUERY_STRING and REQUEST_METHOD = GET. 337 // Run the perl command as a simple process: no logging to the collection's build log338 337 if (runPerlCommand(command_str, envvars, new File(cgi_directory))) 339 338 //new File(GlobalProperties.getGSDL3Home() + File.separator + "WEB-INF" + File.separator + "cgi"))) … … 402 401 } 403 402 404 // ModifyMetadata operations call runSimplePerlCommand which produces no output in build log 403 // If you want to run a Perl command without doing GS2PerlConstructor's custom logging in the build log 404 // The use the runSimplePerlCommand() versions, which use the default behaviour of running a SafeProcess 405 405 protected boolean runSimplePerlCommand(String[] command) { 406 406 return runSimplePerlCommand(command, null, null); … … 417 417 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str)); 418 418 419 logger.info("### Running simple command = " + command_str);419 ///logger.info("### Running simple command = " + command_str); 420 420 421 421 // This is where we create and run our perl process safely … … 459 459 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str)); 460 460 461 logger.info("### Running logged command = " + command_str);461 ///logger.info("### Running logged command = " + command_str); 462 462 463 463 // This is where we create and run our perl process safely … … 526 526 // Now display final message based on exit value 527 527 528 if (perlProcess.getExitValue() == 0) { 529 //status = OK;528 if (perlProcess.getExitValue() == 0) { //status = OK; 529 530 530 sendProcessStatus(new ConstructionEvent(this, GSStatus.CONTINUING, "Success")); 531 532 531 success = true; 533 } else { 534 532 533 } else { //status = ERROR; 535 534 sendProcessStatus(new ConstructionEvent(this, GSStatus.ERROR, "Failure")); 536 537 //return false;538 535 success = false; 539 536 540 537 } 541 } else { // cancelled 538 } else { // cancelled. The code would never come here, including in the old version of runPerlCommand 539 // but leaving this here for an exact port of the old runPerlCommand to the new one which 540 // uses SafeProcess. Also to allow the cancel functionality in future 542 541 543 542 // I need to somehow kill the child process. Unfortunately Thread.stop() and Process.destroy() both fail to do this. But now, thankx to the magic of Michaels 'close the stream suggestion', it works fine. 544 543 sendProcessStatus(new ConstructionEvent(this, GSStatus.HALTED, "killing the process")); 545 //prcs.getOutputStream().close();546 //prcs.destroy();547 ////status = ERROR;548 549 //return false;550 544 success = false; 551 545 } … … 752 746 } 753 747 754 ///System.out.println("@@@ GOT LINE: " + line);755 /// GS2PerlConstructor.logger.info("@@@ GOT LINE: " + line + " STDOUT=1: " + source); 748 ///System.out.println("@@@ GOT LINE: " + line); 749 756 750 757 751 //if(this.source == STDERR) { … … 814 808 bwHandle.write(line + "\n"); 815 809 816 /// System.out.println("@@@ WROTE LINE: " + line);817 810 /// GS2PerlConstructor.logger.info("@@@ WROTE LINE: " + line); 818 811 -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java
r31591 r31592 1026 1026 { 1027 1027 if(allowedMetaFieldsPattern == null) { // null when user has edit permissions, so they can set any meta 1028 logger.info("### User has permissions to set any meta.");1028 ///logger.info("### User has permissions to set any meta."); 1029 1029 return true; 1030 1030 } 1031 1031 if(metaname == null) { 1032 logger.info("### Can't check null metaname against pattern");1032 ///logger.info("### Can't check null metaname against pattern"); 1033 1033 return false; 1034 1034 } … … 1036 1036 Matcher m = allowedMetaFieldsPattern.matcher(metaname); 1037 1037 if(!m.matches()) { 1038 logger.info("### metaname: " + metaname + " doesn't match allowed allowed fields: " + allowedMetaFieldsPattern.toString());1038 ///logger.info("### metaname: " + metaname + " doesn't match allowed allowed fields: " + allowedMetaFieldsPattern.toString()); 1039 1039 return false; 1040 1040 } else { … … 1065 1065 docids[index] = docInfo.getString("docid"); // should exist if metatable existed 1066 1066 1067 logger.info("@@@ Found docid: " + docids[index]);1067 ///logger.info("@@@ Found docid: " + docids[index]); 1068 1068 1069 1069 JSONArray metatable = docInfo.getJSONArray("metatable"); … … 1072 1072 1073 1073 String metaname = meta.getString("metaname"); 1074 logger.info("### metaname: " + metaname);1074 ///logger.info("### metaname: " + metaname); 1075 1075 1076 1076 if(!isAllowedToSetMeta(metaname, filterFields)) { … … 1123 1123 } 1124 1124 1125 // START DEBUG 1125 /* 1126 // FOR DEBUGGING 1126 1127 Set<Map.Entry<String, Serializable>> entries = params.entrySet(); 1127 1128 Iterator<Map.Entry<String, Serializable>> i = entries.iterator(); … … 1138 1139 1139 1140 logger.info("XXXXXXXXXXXXX PARAMETERS:\n" + parametersLine); 1140 // END DEBUG1141 */ 1141 1142 1142 1143 for (String group : context.getGroups()) { -
main/trunk/greenstone3/src/java/org/greenstone/util/SafeProcess.java
r31591 r31592 123 123 124 124 if(this.dir == null) { 125 logger.info("\twith: " + Arrays.toString(this.envp));125 //logger.info("\twith: " + Arrays.toString(this.envp)); 126 126 prcs = rt.exec(this.command_args, this.envp); 127 127 } else { 128 logger.info("\tfrom directory: " + this.dir);129 logger.info("\twith: " + Arrays.toString(this.envp));128 //logger.info("\tfrom directory: " + this.dir); 129 //logger.info("\twith: " + Arrays.toString(this.envp)); 130 130 prcs = rt.exec(this.command_args, this.envp, this.dir); 131 131 } 132 132 } 133 133 } 134 135 logger.info("### Before creating ProcessInGobbler");136 134 137 135 // Create the streamgobblers and set any specified handlers on them … … 146 144 } 147 145 148 logger.info("### Before creating ProcessErrGobbler");149 150 146 // PROC ERR STREAM to monitor for any error messages or expected output in the process' stderr 151 147 if(procErrHandler == null) { … … 157 153 } 158 154 159 logger.info("### Before creating ProcessOutGobbler");160 161 155 // PROC OUT STREAM to monitor for the expected std output line(s) 162 156 if(procOutHandler == null) { … … 169 163 170 164 171 logger.info("### Before streamgobblers.start()");172 173 165 // kick off the stream gobblers 174 166 inputGobbler.start(); … … 176 168 outputGobbler.start(); 177 169 178 logger.info("### After streamgobblers.start() - before waitFor");179 180 170 // any error??? 181 171 this.exitValue = prcs.waitFor(); // can throw an InterruptedException if process did not terminate 182 172 183 logger.info("Process exitValue: " + exitValue); 184 185 logger.info("### Before streamgobblers.join()"); 173 ///logger.info("Process exitValue: " + exitValue); 186 174 187 175 // From the comments of … … 194 182 inputGobbler.join(); 195 183 196 logger.info("### After streamgobblers.join()");197 184 198 185 // set the variables the code that created a SafeProcess object may want to inspect
Note:
See TracChangeset
for help on using the changeset viewer.