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

View File

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