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 456e327..8bc2786 100644 --- a/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java +++ b/agent/src/main/java/io/wdd/agent/executor/CommandExecutor.java @@ -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( 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 5458172..b6dbcb7 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 @@ -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 {