Kaynağa Gözat

shell脚本"\r"问题fix

xueli.xue 8 yıl önce
ebeveyn
işleme
b7935a9323

+ 5 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java Dosyayı Görüntüle

@@ -89,6 +89,11 @@ public class XxlJobServiceImpl implements IXxlJobService {
89 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 97
 		// childJobKey valid
93 98
 		if (StringUtils.isNotBlank(jobInfo.getChildJobKey())) {
94 99
 			String[] childJobKeys = jobInfo.getChildJobKey().split(",");

+ 11 - 9
xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl Dosyayı Görüntüle

@@ -208,19 +208,21 @@ exit 0
208 208
 <textarea class="glueSource_python" style="display:none;" >
209 209
 #!/usr/bin/python
210 210
 # -*- coding: UTF-8 -*-
211
-
212
-import logging
213 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 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 226
 </textarea>
225 227
 					
226 228
 				</form>

+ 2 - 2
xxl-job-core/src/main/java/com/xxl/job/core/thread/JobThread.java Dosyayı Görüntüle

@@ -88,7 +88,7 @@ public class JobThread extends Thread{
88 88
 						}
89 89
 					} catch (Exception e) {
90 90
 						if (toStop) {
91
-							logger.error("----------- xxl-job toStop, stopReason:{}", stopReason);
91
+							logger.error("<br>----------- xxl-job toStop, stopReason:{}", stopReason);
92 92
 						}
93 93
 						logger.error("JobThread Exception:", e);
94 94
 						StringWriter out = new StringWriter();
@@ -111,7 +111,7 @@ public class JobThread extends Thread{
111 111
 				}
112 112
 			} catch (Exception e) {
113 113
 				if (toStop) {
114
-					logger.error("----------- xxl-job toStop, stopReason:{}", stopReason);
114
+					logger.error("<br>----------- xxl-job toStop, stopReason:{}", stopReason);
115 115
 				}
116 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 Dosyayı Görüntüle

@@ -87,7 +87,7 @@ public class ScriptUtil {
87 87
         DefaultExecutor exec = new DefaultExecutor();
88 88
         exec.setExitValues(null);
89 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 91
         return exitValue;
92 92
     }
93 93