撤销spawn修改

This commit is contained in:
hanhh 2021-07-08 10:24:40 +08:00
parent 22a23fe05e
commit 6cd0feaace

View File

@ -211,17 +211,18 @@ export default class CronService {
cmdStr = `${cmdStr} now`;
}
const cp = exec(cmdStr, (err, stdout, stderr) => {
const cp = spawn(cmdStr, { shell: true, detached: true });
this.cronDb.update(
{ _id },
{ $set: { status: CrontabStatus.running, pid: cp.pid } },
);
cp.on('close', (code) => {
this.cronDb.update(
{ _id },
{ $set: { status: CrontabStatus.idle }, $unset: { pid: true } },
);
resolve();
});
this.cronDb.update(
{ _id },
{ $set: { status: CrontabStatus.running, pid: cp.pid } },
);
});
}