Quellcode durchsuchen

shell脚本"\r"问题fix

xueli.xue vor 8 Jahren
Ursprung
Commit
b7935a9323

+ 5 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java Datei anzeigen

89
 			return new ReturnT<String>(500, "请输入“JobHandler”");
89
 			return new ReturnT<String>(500, "请输入“JobHandler”");
90
 		}
90
 		}
91
 
91
 
92
+		// fix "\r" in shell
93
+		if (GlueTypeEnum.GLUE_SHELL==GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource()!=null) {
94
+			jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", ""));
95
+		}
96
+
92
 		// childJobKey valid
97
 		// childJobKey valid
93
 		if (StringUtils.isNotBlank(jobInfo.getChildJobKey())) {
98
 		if (StringUtils.isNotBlank(jobInfo.getChildJobKey())) {
94
 			String[] childJobKeys = jobInfo.getChildJobKey().split(",");
99
 			String[] childJobKeys = jobInfo.getChildJobKey().split(",");

+ 11 - 9
xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl Datei anzeigen

208
 <textarea class="glueSource_python" style="display:none;" >
208
 <textarea class="glueSource_python" style="display:none;" >
209
 #!/usr/bin/python
209
 #!/usr/bin/python
210
 # -*- coding: UTF-8 -*-
210
 # -*- coding: UTF-8 -*-
211
-
212
-import logging
213
 import time
211
 import time
212
+import sys
214
 
213
 
215
-logging.basicConfig(level=logging.DEBUG)
216
-
217
-logging.info('xxl-job: hello python')
218
-
219
-for num in range(1, 3):
214
+print "xxl-job: hello python"
215
+print "脚本文件:", sys.argv[0]
216
+for i in range(1, len(sys.argv)):
220
 	time.sleep(1)
217
 	time.sleep(1)
221
-	logging.info('python :' + str(num) )
218
+	print "参数", i, sys.argv[i]
222
 
219
 
223
-logging.info('Good bye!')
220
+print "Good bye!"
221
+exit(0)<#--
222
+import logging
223
+logging.basicConfig(level=logging.DEBUG)
224
+logging.info("脚本文件:" + sys.argv[0])
225
+-->
224
 </textarea>
226
 </textarea>
225
 					
227
 					
226
 				</form>
228
 				</form>

+ 2 - 2
xxl-job-core/src/main/java/com/xxl/job/core/thread/JobThread.java Datei anzeigen

88
 						}
88
 						}
89
 					} catch (Exception e) {
89
 					} catch (Exception e) {
90
 						if (toStop) {
90
 						if (toStop) {
91
-							logger.error("----------- xxl-job toStop, stopReason:{}", stopReason);
91
+							logger.error("<br>----------- xxl-job toStop, stopReason:{}", stopReason);
92
 						}
92
 						}
93
 						logger.error("JobThread Exception:", e);
93
 						logger.error("JobThread Exception:", e);
94
 						StringWriter out = new StringWriter();
94
 						StringWriter out = new StringWriter();
111
 				}
111
 				}
112
 			} catch (Exception e) {
112
 			} catch (Exception e) {
113
 				if (toStop) {
113
 				if (toStop) {
114
-					logger.error("----------- xxl-job toStop, stopReason:{}", stopReason);
114
+					logger.error("<br>----------- xxl-job toStop, stopReason:{}", stopReason);
115
 				}
115
 				}
116
 				logger.error("----------- xxl-job JobThread Exception:", e);
116
 				logger.error("----------- xxl-job JobThread Exception:", e);
117
 			}
117
 			}

+ 1 - 1
xxl-job-core/src/main/java/com/xxl/job/core/util/ScriptUtil.java Datei anzeigen

87
         DefaultExecutor exec = new DefaultExecutor();
87
         DefaultExecutor exec = new DefaultExecutor();
88
         exec.setExitValues(null);
88
         exec.setExitValues(null);
89
         exec.setStreamHandler(streamHandler);
89
         exec.setStreamHandler(streamHandler);
90
-        int exitValue = exec.execute(commandline);  // exit code: 0=success, 1/-1=fail
90
+        int exitValue = exec.execute(commandline);  // exit code: 0=success, 1=error
91
         return exitValue;
91
         return exitValue;
92
     }
92
     }
93
 
93