[ server ] [ scheduler ]- script scheduler - 4
This commit is contained in:
@@ -51,13 +51,14 @@ public class OMHandlerExecutor extends AbstractOctopusMessageHandler {
|
||||
// add in 2023-1-17
|
||||
if (CollectionUtils.isNotEmpty(executionMessage.getScriptCommandList())) {
|
||||
// 传递的是 页面定时任务脚本
|
||||
isScheduledScript = true;
|
||||
functionExecutor.execute(executionMessage, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
String executionType = executionMessage.getType();
|
||||
if (ALL_FUNCTION_MAP.containsKey(executionType)) {
|
||||
// execute the exist function
|
||||
functionExecutor.execute(executionMessage, isScheduledScript);
|
||||
functionExecutor.execute(executionMessage, false);
|
||||
} else {
|
||||
// handle command
|
||||
commandExecutor.execute(executionMessage);
|
||||
|
||||
@@ -47,6 +47,57 @@ public class CommandExecutor {
|
||||
|
||||
}
|
||||
|
||||
/*public int executeScript(String streamKey, List<String> commandList) {
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(commandList);
|
||||
|
||||
processBuilder.redirectErrorStream(true);
|
||||
// processBuilder.inheritIO();
|
||||
processBuilder.directory(new File(System.getProperty("user.home")));
|
||||
int processResult = 233;
|
||||
|
||||
try {
|
||||
|
||||
Process process = processBuilder.start();
|
||||
|
||||
// start a backend thread to daemon the process
|
||||
// wait for processMaxWaitSeconds and kill the process if it's still alived
|
||||
DaemonCommandProcess.submit(
|
||||
StopStuckCommandProcess(
|
||||
process,
|
||||
processMaxWaitSeconds
|
||||
));
|
||||
|
||||
// todo this will stuck the process and rabbitmq message will reentry the queue
|
||||
// get the command result must also be a timeout smaller than the process
|
||||
boolean waitFor = process.waitFor(
|
||||
50,
|
||||
TimeUnit.SECONDS
|
||||
);
|
||||
|
||||
// get the process result
|
||||
if (ObjectUtils.isNotEmpty(waitFor) && ObjectUtils.isNotEmpty(process)) {
|
||||
processResult = process.exitValue();
|
||||
}
|
||||
|
||||
log.debug(
|
||||
"current shell command {} result is {}",
|
||||
processBuilder.command(),
|
||||
processResult
|
||||
);
|
||||
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
log.error(
|
||||
"Shell command error ! {} + {}",
|
||||
e.getCause(),
|
||||
e.getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
return processResult;
|
||||
|
||||
}*/
|
||||
|
||||
public int execute(String streamKey, List<String> command) {
|
||||
|
||||
|
||||
@@ -28,11 +28,6 @@ public class FunctionExecutor {
|
||||
NacosConfigurationCollector nacosConfigurationCollector;
|
||||
|
||||
|
||||
public void executeScriptScheduler(ExecutionMessage executionMessage) {
|
||||
|
||||
executionMessage.getScriptCommandList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void execute(ExecutionMessage executionMessage, boolean isScheduledScript) {
|
||||
|
||||
Reference in New Issue
Block a user