增加停止指定命令接口

This commit is contained in:
whyour committed 2023-05-01 22:56:47 +08:00
1 parent 8db997abe8
commit 0af687f781
5 files changed
+42 -8

No files matched your search

+3 -4
View File
@@ -496,10 +496,9 @@ export async function killTask(pid: number) {
}
export async function getPid(name: string) {
let taskCommand = `ps -ef | grep "${name}" | grep -v grep | awk '{print $1}'`;
const execAsync = promisify(exec);
let pid = (await execAsync(taskCommand)).stdout;
return Number(pid);
const taskCommand = `ps -eo pid,command | grep "${name}" | grep -v grep | awk '{print $1}' | head -1 | xargs echo -n`;
const pid = await promiseExec(taskCommand);
return pid ? Number(pid) : undefined;
}
interface IVersion {