mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-15 05:33:27 +08:00
使用 spawn exit 方法监听进程退出
This commit is contained in:
@@ -427,7 +427,7 @@ export default class CronService {
|
|||||||
fs.appendFileSync(`${absolutePath}`, `${JSON.stringify(err)}`);
|
fs.appendFileSync(`${absolutePath}`, `${JSON.stringify(err)}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
cp.on('close', async (code) => {
|
cp.on('exit', async (code) => {
|
||||||
await CrontabModel.update(
|
await CrontabModel.update(
|
||||||
{ status: CrontabStatus.idle, pid: undefined },
|
{ status: CrontabStatus.idle, pid: undefined },
|
||||||
{ where: { id } },
|
{ where: { id } },
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ export default class DependenceService {
|
|||||||
this.updateLog(depIds, JSON.stringify(err));
|
this.updateLog(depIds, JSON.stringify(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
cp.on('close', async (code) => {
|
cp.on('exit', async (code) => {
|
||||||
const endTime = dayjs();
|
const endTime = dayjs();
|
||||||
const isSucceed = code === 0;
|
const isSucceed = code === 0;
|
||||||
const resultText = isSucceed ? '成功' : '失败';
|
const resultText = isSucceed ? '成功' : '失败';
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export default class ScheduleService {
|
|||||||
await callbacks.onError?.(JSON.stringify(err));
|
await callbacks.onError?.(JSON.stringify(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
cp.on('close', async (code) => {
|
cp.on('exit', async (code) => {
|
||||||
const endTime = dayjs();
|
const endTime = dayjs();
|
||||||
await callbacks.onEnd?.(
|
await callbacks.onEnd?.(
|
||||||
cp,
|
cp,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export function runCron(cmd: string, options?: { schedule: string; extraSchedule
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
cp.on('close', async (code) => {
|
cp.on('exit', async (code) => {
|
||||||
resolve({ ...options, command: cmd, pid: cp.pid, code });
|
resolve({ ...options, command: cmd, pid: cp.pid, code });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user