From 540ade5c937dc0352e3af957724108b90cb5af9a Mon Sep 17 00:00:00 2001 From: zeaslity Date: Sun, 26 Feb 2023 15:48:50 +0800 Subject: [PATCH] [agent][executor]- bug - 13 --- .../wdd/agent/executor/CommandExecutor.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) 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 b3f56af..7e3bb50 100644 --- a/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java +++ b/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java @@ -122,15 +122,8 @@ public class CommandExecutor { octopusMessage )); - // 缓存 命令处理日志 - // 如果是特别简单的命令,必须要放在此处才可以,否则会导致 无法收集 - commandExecLogCache.cacheLog( - streamKey, - process - ); - // 等待1秒钟, 使得有时间进行后端任务的完成 - //TimeUnit.SECONDS.sleep(1); + TimeUnit.SECONDS.sleep(1); // get the command result must also be a timeout smaller than the process // 此处会把主线程卡死, forever终结 @@ -139,15 +132,6 @@ public class CommandExecutor { // 命令执行完成, countDownLatch计数 countDownLatch.countDown(); - // 打印一下 debug - commandExecLogCache.PrintCommandCachedLog(streamKey); - - // 关停任务执行的缓存日志收集 BufferedReader 否则无法终止 - commandExecLogCache.StopExecLogBufferedReader( - streamKey, - process - ); - log.debug( "current shell command {} result is {}", processBuilder.command(), @@ -191,6 +175,13 @@ public class CommandExecutor { System.out.println("process isAlive = " + process.isAlive()); + // 缓存 命令处理日志 + // 如果是特别简单的命令,必须要放在此处才可以,否则会导致 无法收集 + commandExecLogCache.cacheLog( + streamKey, + process + ); + // 任务提前执行结束,或者超过了最长等待时间 // 判断命令是否正确处理完成 if (!commandExecComplete) { @@ -219,6 +210,12 @@ public class CommandExecutor { // 打印一下 debug commandExecLogCache.PrintCommandCachedLog(streamKey); + // 关停任务执行的缓存日志收集 BufferedReader 否则无法终止 + commandExecLogCache.StopExecLogBufferedReader( + streamKey, + process + ); + // 异步执行日志的发送工作 //commandExecLogCache.CollectAndSendExecLog(streamKey, needResultReplay, octopusMessage);