fix: ASW-164 playbook 添加 cancel 接口

This commit is contained in:
zhangshuai
2024-11-14 14:28:30 +08:00
parent 8b540ba127
commit 7eb847d7bf
2 changed files with 55 additions and 8 deletions

View File

@@ -9,9 +9,7 @@ import net.geedge.common.Constant;
import net.geedge.common.RCode;
import net.geedge.common.T;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.io.*;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.*;
@@ -37,6 +35,8 @@ public class AdbUtil {
private CommandExec commandExec;
private boolean interrupt;
private ExecutorService threadPool;
@@ -44,6 +44,10 @@ public class AdbUtil {
return T.StrUtil.isNotEmpty(this.serial) ? serial : String.format("%s:%s", this.host, this.port);
}
public void setInterrupt(boolean interrupt) {
this.interrupt = interrupt;
}
public record CommandResult(Integer exitCode, String output) {
}
@@ -870,6 +874,10 @@ public class AdbUtil {
bufferedReader = new BufferedReader(inputStreamReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
if (T.ObjectUtil.isNotNull(interrupt) && interrupt){
log.info("[PlaybookRunnable] [execPlaybook] [stop exec playbook]");
process.destroyForcibly();
}
// 处理每一行输出
T.FileUtil.appendString(T.StrUtil.concat(true, line, "\n"), logFile, "UTF-8");
}