diff --git a/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java b/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java index 7716a9f..b4de18c 100644 --- a/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java +++ b/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java @@ -166,7 +166,7 @@ public class CommandExecutor { try { log.debug( - "[ {} ]命令执行守护进程开始等待 {} s for the result", + "[ {} ] 命令执行守护进程开始等待 {} 秒", process .info() .commandLine() @@ -184,11 +184,7 @@ public class CommandExecutor { throw new RuntimeException(e); } finally { - // 缓存 命令处理日志 - commandExecLogCache.cacheLog( - streamKey, - process - ); + // 任务提前执行结束,或者超过了最长等待时间 // 判断命令是否正确处理完成 @@ -201,8 +197,23 @@ public class CommandExecutor { .get(), commandExecWaitTimeout ); + + + // 命令没有正确的处理完成,需要手动关停程序 + // 只有当该进程还存活,执行关闭操作 + if (process.isAlive()) { + // shutdown the process + log.debug("开始销毁命令执行进程!"); + process.destroy(); + } } + // 缓存 命令处理日志 + commandExecLogCache.cacheLog( + streamKey, + process + ); + // 日志操作,如果需要显示回传,需要将日志发送回相应的 collectCommandLogAndRepeat( streamKey, @@ -210,13 +221,6 @@ public class CommandExecutor { octopusMessage ); - // 只有当该进程还存活,执行关闭操作 - if (process.isAlive()) { - // shutdown the process - log.debug("开始销毁命令执行进程!"); - process.destroyForcibly(); - } - } }; }