shell脚本"\r"问题fix

v1.7
xueli.xue 8 years ago
parent b30fceb46d
commit b7935a9323

@ -89,6 +89,11 @@ public class XxlJobServiceImpl implements IXxlJobService {
return new ReturnT<String>(500, "请输入“JobHandler”");
}
// fix "\r" in shell
if (GlueTypeEnum.GLUE_SHELL==GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource()!=null) {
jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", ""));
}
// childJobKey valid
if (StringUtils.isNotBlank(jobInfo.getChildJobKey())) {
String[] childJobKeys = jobInfo.getChildJobKey().split(",");

@ -208,19 +208,21 @@ exit 0
<textarea class="glueSource_python" style="display:none;" >
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import logging
import time
import sys
logging.basicConfig(level=logging.DEBUG)
logging.info('xxl-job: hello python')
for num in range(1, 3):
print "xxl-job: hello python"
print "脚本文件:", sys.argv[0]
for i in range(1, len(sys.argv)):
time.sleep(1)
logging.info('python :' + str(num) )
print "参数", i, sys.argv[i]
logging.info('Good bye!')
print "Good bye!"
exit(0)<#--
import logging
logging.basicConfig(level=logging.DEBUG)
logging.info("脚本文件:" + sys.argv[0])
-->
</textarea>
</form>

@ -88,7 +88,7 @@ public class JobThread extends Thread{
}
} catch (Exception e) {
if (toStop) {
logger.error("----------- xxl-job toStop, stopReason:{}", stopReason);
logger.error("<br>----------- xxl-job toStop, stopReason:{}", stopReason);
}
logger.error("JobThread Exception:", e);
StringWriter out = new StringWriter();
@ -111,7 +111,7 @@ public class JobThread extends Thread{
}
} catch (Exception e) {
if (toStop) {
logger.error("----------- xxl-job toStop, stopReason:{}", stopReason);
logger.error("<br>----------- xxl-job toStop, stopReason:{}", stopReason);
}
logger.error("----------- xxl-job JobThread Exception:", e);
}

@ -87,7 +87,7 @@ public class ScriptUtil {
DefaultExecutor exec = new DefaultExecutor();
exec.setExitValues(null);
exec.setStreamHandler(streamHandler);
int exitValue = exec.execute(commandline); // exit code: 0=success, 1/-1=fail
int exitValue = exec.execute(commandline); // exit code: 0=success, 1=error
return exitValue;
}

Loading…
Cancel
Save