[agent][executor]- bug - 10

This commit is contained in:
zeaslity
2023-02-26 12:07:51 +08:00
parent f2be1dfb5c
commit e73b475680
2 changed files with 37 additions and 2 deletions

View File

@@ -219,6 +219,9 @@ public class CommandExecutor {
}
// 打印一下 debug
commandExecLogCache.PrintCommandCachedLog(streamKey);
// 异步执行日志的发送工作
//commandExecLogCache.CollectAndSendExecLog(streamKey, needResultReplay, octopusMessage);
@@ -229,7 +232,6 @@ public class CommandExecutor {
);
// 释放所有的资源
try {
process
.getInputStream()

View File

@@ -1,6 +1,8 @@
package io.wdd.agent.executor.thread;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.wdd.agent.config.utils.AgentCommonThreadPool;
import io.wdd.agent.executor.reply.SimpleStreamSender;
import io.wdd.agent.message.OMessageToServerSender;
@@ -44,6 +46,9 @@ public class CommandExecLogCache {
@Resource
OMessageToServerSender toServerSender;
@Resource
ObjectMapper objectMapper;
/**
* 缓存命令执行日志
*
@@ -145,7 +150,6 @@ public class CommandExecLogCache {
*/
public void StopExecLogBufferedReader(String streamKey) {
BufferedReader bufferedReader = CommandLogReaderMap.get(streamKey);
log.debug(
@@ -164,6 +168,35 @@ public class CommandExecLogCache {
}
/**
* 漂亮的打印出缓存的日志内容
*
* @param streamKey
*/
public void PrintCommandCachedLog(String streamKey) {
ArrayList<String> cachedCommandLog = CachedCommandLogMap.getOrDefault(
streamKey,
EmptyCommandLog
);
try {
String s = objectMapper
.writerWithDefaultPrettyPrinter()
.writeValueAsString(cachedCommandLog);
log.info("任务 [ {} ] 的缓存执行结果为 \n{}",
streamKey,
s
);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
/**
* 日志回传操作
* 默认发送值Redis中