mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-07 11:56:08 +08:00
修复python3任务无法停止
This commit is contained in:
parent
bcac3deb6e
commit
0bf4aec74e
|
@ -241,19 +241,19 @@ export default class CronService {
|
|||
}
|
||||
|
||||
private async killTask(name: string) {
|
||||
let taskCommond = `ps -ef | grep "${name}" | grep -v grep | awk '{print $1}'`;
|
||||
let taskCommand = `ps -ef | grep "${name}" | grep -v grep | awk '{print $1}'`;
|
||||
const execAsync = promisify(exec);
|
||||
try {
|
||||
let pid = (await execAsync(taskCommond)).stdout;
|
||||
let pid = (await execAsync(taskCommand)).stdout;
|
||||
if (pid) {
|
||||
pid = (await execAsync(`pstree -p ${pid}`)).stdout;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
const pids = pid.match(/\d+/g);
|
||||
const pids = pid.match(/\(\d+/g);
|
||||
const killLogs = [];
|
||||
for (const id of pids) {
|
||||
const c = `kill -9 ${id}`;
|
||||
const c = `kill -9 ${id.slice(1)}`;
|
||||
const { stdout, stderr } = await execAsync(c);
|
||||
if (stderr) {
|
||||
killLogs.push(stderr);
|
||||
|
|
Loading…
Reference in New Issue
Block a user