[agent][executor]- bug - 2

This commit is contained in:
zeaslity
2023-02-25 18:55:49 +08:00
parent bd5dd0ea09
commit 3c245b126e
2 changed files with 41 additions and 1 deletions

View File

@@ -205,12 +205,16 @@ public class CommandExecutor {
if (process.isAlive()) { if (process.isAlive()) {
// shutdown the process // shutdown the process
log.debug( log.debug(
"开始销毁命令[ {} ]执行进程!", "开始销毁命令 [ {} ] 执行进程!",
process process
.info() .info()
.commandLine() .commandLine()
.get() .get()
); );
// 对线程进行debug
commandExecLogCache.debugProcessStreams(process);
process.destroy(); process.destroy();
} }
} }

View File

@@ -104,6 +104,42 @@ public class CommandExecLogCache {
return execLogCacheArrayList; 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
);
}
/** /**
* 实际执行命令缓存操作 * 实际执行命令缓存操作
* *