[agent][executor]- bug - 10

This commit is contained in:
zeaslity
2023-02-26 14:40:49 +08:00
parent 3f7f4c2e0b
commit e0e2078ae0
2 changed files with 13 additions and 9 deletions

View File

@@ -40,7 +40,7 @@ public class CommandExecutor {
/** /**
* 一个命令执行的最长等待时间 * 一个命令执行的最长等待时间
*/ */
int processMaxWaitSeconds = 20; int processMaxWaitSeconds = 10;
/** /**
* 持久化命令执行的最长等待时间 * 持久化命令执行的最长等待时间
@@ -215,7 +215,10 @@ public class CommandExecutor {
} }
// 关停任务执行的缓存日志收集 BufferedReader 否则无法终止 // 关停任务执行的缓存日志收集 BufferedReader 否则无法终止
commandExecLogCache.StopExecLogBufferedReader(streamKey); commandExecLogCache.StopExecLogBufferedReader(
streamKey,
process
);
} }

View File

@@ -148,7 +148,7 @@ public class CommandExecLogCache {
* 对于一些没有中止的任务,必须要手动将读取的 InputStream流关闭 * 对于一些没有中止的任务,必须要手动将读取的 InputStream流关闭
* 否则部分任务的日志无法收集 * 否则部分任务的日志无法收集
*/ */
public void StopExecLogBufferedReader(String streamKey) { public void StopExecLogBufferedReader(String streamKey, Process process) {
BufferedReader bufferedReader = CommandLogReaderMap.get(streamKey); BufferedReader bufferedReader = CommandLogReaderMap.get(streamKey);
@@ -160,7 +160,14 @@ public class CommandExecLogCache {
if (ObjectUtils.isNotEmpty(bufferedReader)) { if (ObjectUtils.isNotEmpty(bufferedReader)) {
try { try {
// 关闭command的输出流
process
.getInputStream()
.close();
bufferedReader.close(); bufferedReader.close();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -185,12 +192,6 @@ public class CommandExecLogCache {
.writerWithDefaultPrettyPrinter() .writerWithDefaultPrettyPrinter()
.writeValueAsString(cachedCommandLog); .writeValueAsString(cachedCommandLog);
log.info(
"任务 [ {} ] 的缓存执行结果为 \n{}",
streamKey,
s
);
System.out.println("s = " + s); System.out.println("s = " + s);