[agent][executor]- bug - 3

This commit is contained in:
zeaslity
2023-02-25 22:01:20 +08:00
parent d3b36270c5
commit 018d782713
2 changed files with 6 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
@@ -90,7 +91,7 @@ public class CommandExecutor {
// 重定向,错误日志到标准输出中
processBuilder.redirectErrorStream(true);
// processBuilder.inheritIO();
// processBuilder.directory(new File(System.getProperty("user.home")));
processBuilder.directory(new File(System.getProperty("user.home")));
int processResult = 233;
try {
@@ -181,7 +182,6 @@ public class CommandExecutor {
throw new RuntimeException(e);
} finally {
// 任务提前执行结束,或者超过了最长等待时间
// 判断命令是否正确处理完成
if (!commandExecComplete) {
@@ -194,7 +194,6 @@ public class CommandExecutor {
commandExecWaitTimeout
);
// 命令没有正确的处理完成,需要手动关停程序
// 只有当该进程还存活,执行关闭操作, 没有返回结果的命令如 ping baidu.com 只有在线程关闭之后才可以有结果s
if (process.isAlive()) {
@@ -221,11 +220,11 @@ public class CommandExecutor {
);
// 日志操作,如果需要显示回传,需要将日志发送回相应的
collectCommandLogAndRepeat(
/*collectCommandLogAndRepeat(
streamKey,
needResultReplay,
octopusMessage
);
);*/
// 执行到这里,说明整个任务流程结束
log.debug(

View File

@@ -5,7 +5,7 @@ import io.wdd.common.handler.MyRuntimeException;
import io.wdd.common.utils.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -18,7 +18,7 @@ import java.util.HashMap;
* utils to cache store the command execution logs
* 2023年2月22日 同样需要取出存着的日志
*/
@Component
@Service
@Slf4j
public class CommandExecLogCache {