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”"); 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 // childJobKey valid
if (StringUtils.isNotBlank(jobInfo.getChildJobKey())) { if (StringUtils.isNotBlank(jobInfo.getChildJobKey())) {
String[] childJobKeys = jobInfo.getChildJobKey().split(","); String[] childJobKeys = jobInfo.getChildJobKey().split(",");

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

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

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

Loading…
Cancel
Save