Commit 5b9da215 by huangfusuper

解决脚本运行不通知异常的BUG

parent 7f690086
...@@ -32,7 +32,7 @@ public class WaitingRecordServiceImpl implements WaitingRecordService { ...@@ -32,7 +32,7 @@ public class WaitingRecordServiceImpl implements WaitingRecordService {
*/ */
@Override @Override
public List<WaitingRecord> findAllByTriggerTime(long triggerTime) { public List<WaitingRecord> findAllByTriggerTime(long triggerTime) {
log.info("------查询对应的等待工作流--------"); log.debug("------查询对应的等待工作流--------");
return waitingRecordMapper.findAllByTriggerTime(triggerTime); return waitingRecordMapper.findAllByTriggerTime(triggerTime);
} }
......
...@@ -29,7 +29,7 @@ import java.util.Date; ...@@ -29,7 +29,7 @@ import java.util.Date;
public class ScriptExecutorJobTask implements TimerTask { public class ScriptExecutorJobTask implements TimerTask {
private final String HTTP_PRE = "http://"; private final String HTTP_PRE = "http://";
private final String HTTP_SUFFIX = "/job/callbackRes"; private final String HTTP_SUFFIX = "/myth-job-admin/job/callbackRes";
private JobTaskSchedule mythJobTaskSchedule; private JobTaskSchedule mythJobTaskSchedule;
...@@ -101,16 +101,16 @@ public class ScriptExecutorJobTask implements TimerTask { ...@@ -101,16 +101,16 @@ public class ScriptExecutorJobTask implements TimerTask {
try{ try{
dispatchResponseDto = runScriptService.runScript(scriptDto); dispatchResponseDto = runScriptService.runScript(scriptDto);
}catch (RpcException rpcException){ }catch (RpcException rpcException){
log.error("------执行机异常{}-----",rpcException.getMessage());
dispatchResponseDto.setMsg(rpcException.getMessage()); dispatchResponseDto.setMsg(rpcException.getMessage());
dispatchResponseDto.setCode(JobResultEnum.DISPATCH_FAIL.getRes()); dispatchResponseDto.setCode(JobResultEnum.DISPATCH_FAIL.getRes());
log.error("--------------执行机不存在----------------");
} }
saveLog(mythJobTaskSchedule,dispatchResponseDto); saveLog(mythJobTaskSchedule,dispatchResponseDto);
} }
private void saveLog(JobTaskSchedule mythJobTaskSchedule, DispatchResponseDto dispatchResponseDto){ private void saveLog(JobTaskSchedule mythJobTaskSchedule, DispatchResponseDto dispatchResponseDto){
log.info("-----------saveLog--保存脚本调度日志开始------------"); log.debug("-----------saveLog--保存脚本调度日志开始------------");
JobTaskRunLogServiceImpl jobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class); JobTaskRunLogServiceImpl jobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class);
JobTaskRunLogWithBLOBs jobTaskRunLogById = jobTaskRunLogService.findJobTaskRunLogById(mythJobTaskSchedule.getLogId()); JobTaskRunLogWithBLOBs jobTaskRunLogById = jobTaskRunLogService.findJobTaskRunLogById(mythJobTaskSchedule.getLogId());
......
...@@ -54,9 +54,29 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService { ...@@ -54,9 +54,29 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService {
@Override @Override
public DispatchResponseDto runPythonScript(ScriptDto scriptDto) { public DispatchResponseDto runPythonScript(ScriptDto scriptDto) {
log.info("----------------runPythonScript start{} ------------------------",scriptDto);
DispatchResponseDto dispatchResponseDto; DispatchResponseDto dispatchResponseDto;
try { try {
RunThreadPool.SCRIPT_RUN_THREAD_POOL.execute(()->{ RunThreadPool.SCRIPT_RUN_THREAD_POOL.execute(()->{
startScript(scriptDto);
});
dispatchResponseDto = DispatchResponseDto.builder()
.code(JobResultEnum.DISPATCH_SUCCESS.getCode())
.msg(JobResultEnum.DISPATCH_SUCCESS.getMsg())
.build();
}catch (Exception e){
dispatchResponseDto = DispatchResponseDto.builder()
.code(JobResultEnum.DISPATCH_FAIL.getCode())
.msg(JobResultEnum.DISPATCH_FAIL.getMsg())
.build();
}
dispatchResponseDto.setUrl(ServiceInfoUtil.getIpAndPort());
log.info("----------------runPythonScript end---------------------");
return dispatchResponseDto;
}
public void startScript(ScriptDto scriptDto){
log.info("--------------runPythonScript,脚本调用开始-----------"); log.info("--------------runPythonScript,脚本调用开始-----------");
//创建回复对象 //创建回复对象
JobRunResultDto jobRunResultDto = new JobRunResultDto(); JobRunResultDto jobRunResultDto = new JobRunResultDto();
...@@ -121,21 +141,6 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService { ...@@ -121,21 +141,6 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService {
jobRunResultDto.setLogRemotelyPath(logPath); jobRunResultDto.setLogRemotelyPath(logPath);
cn.hutool.http.HttpUtil.post(callbackUrl, JSON.toJSONString(jobRunResultDto)); cn.hutool.http.HttpUtil.post(callbackUrl, JSON.toJSONString(jobRunResultDto));
log.info("--------------runPythonScript,脚本调用结束-----------"); log.info("--------------runPythonScript,脚本调用结束-----------");
});
dispatchResponseDto = DispatchResponseDto.builder()
.code(JobResultEnum.DISPATCH_SUCCESS.getCode())
.msg(JobResultEnum.DISPATCH_SUCCESS.getMsg())
.build();
}catch (Exception e){
dispatchResponseDto = DispatchResponseDto.builder()
.code(JobResultEnum.DISPATCH_FAIL.getCode())
.msg(JobResultEnum.DISPATCH_FAIL.getMsg())
.build();
}
dispatchResponseDto.setUrl(ServiceInfoUtil.getIpAndPort());
return dispatchResponseDto;
} }
......
...@@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit; ...@@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit;
public class AddComplexPy { public class AddComplexPy {
public static void main(String[] args) { public static void main(String[] args) {
RunNode runNode = new RunNode(); RunNode runNode = new RunNode();
runNode.setScriptUrl("ddmp/M00/00/00/CgB4Al5wa36AaUJ7AAAAiYy1k-k9801.py"); runNode.setScriptUrl("ddmp/M00/00/01/CgB4Al5wa6WAfhQ9AAAAN9Xm1mU1221.py");
runNode.setJobType("PYTHON"); runNode.setJobType("PYTHON");
runNode.setNodeId("2"); runNode.setNodeId("2");
runNode.setNodeName("lijkki"); runNode.setNodeName("lijkki");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment