From 29e7db26d9f85174f1a41b395933004ed3d602be Mon Sep 17 00:00:00 2001 From: zeaslity Date: Sat, 25 Feb 2023 22:42:43 +0800 Subject: [PATCH] [agent][executor]- bug - 5 --- .../wdd/agent/executor/CommandExecutor.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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 5b9efb3..9605f1f 100644 --- a/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java +++ b/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java @@ -8,6 +8,7 @@ import io.wdd.agent.executor.thread.CommandExecLogCache; import io.wdd.agent.message.OMessageToServerSender; import io.wdd.common.beans.executor.ExecutionMessage; import io.wdd.common.beans.rabbitmq.OctopusMessage; +import io.wdd.common.handler.MyRuntimeException; import io.wdd.common.utils.TimeUtils; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -21,7 +22,9 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; @Configuration @@ -217,7 +220,27 @@ public class CommandExecutor { // 对线程进行debug commandExecLogCache.debugProcessStreams(process); + try { + TimeUnit.SECONDS.sleep(3); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + process.destroy(); + + try { + Process exitProcess = process + .onExit() + .get( + commandExecWaitTimeout, + TimeUnit.SECONDS + ); + + + commandExecLogCache.debugProcessStreams(exitProcess); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + throw new MyRuntimeException(e); + } } }