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 fc92d40..b6395ef 100644 --- a/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java +++ b/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java @@ -205,12 +205,16 @@ public class CommandExecutor { if (process.isAlive()) { // shutdown the process log.debug( - "开始销毁命令[ {} ]执行进程!", + "开始销毁命令 [ {} ] 执行进程!", process .info() .commandLine() .get() ); + + // 对线程进行debug + commandExecLogCache.debugProcessStreams(process); + process.destroy(); } } diff --git a/agent/src/main/java/io/wdd/agent/executor/thread/CommandExecLogCache.java b/agent/src/main/java/io/wdd/agent/executor/thread/CommandExecLogCache.java index 179c938..9b0e30f 100644 --- a/agent/src/main/java/io/wdd/agent/executor/thread/CommandExecLogCache.java +++ b/agent/src/main/java/io/wdd/agent/executor/thread/CommandExecLogCache.java @@ -104,6 +104,42 @@ public class CommandExecLogCache { return execLogCacheArrayList; } + /** + * 调试打印process哥各个 流 + * + * @param process + */ + public void debugProcessStreams(Process process) { + + log.debug( + "开始对一个process进行debug操作,process的信息为 {}, 执行时间为 {} , 执行结果为 {}", + process + .info() + .commandLine(), + process + .info() + .totalCpuDuration() + .get(), + process.exitValue() + ); + + log.debug("------------- inputStream -----------"); + new BufferedReader(new InputStreamReader(process.getInputStream())) + .lines() + .forEach( + System.out::println + ); + + + log.debug("------------- errorStream -----------"); + new BufferedReader(new InputStreamReader(process.getErrorStream())) + .lines() + .forEach( + System.out::println + ); + + } + /** * 实际执行命令缓存操作 *