执行任务增加结束日志

This commit is contained in:
whyour
2024-08-31 14:43:44 +08:00
parent a48d100b2d
commit 7414a9d33d
3 changed files with 39 additions and 4 deletions
+16 -1
View File
@@ -431,7 +431,7 @@ export default class CronService {
}
this.logger.info(
`[panel][开始执行任务] 参数 ${JSON.stringify(params)}`,
`[panel][开始执行任务] 参数: ${JSON.stringify(params)}`,
);
let { id, command, log_path } = cron;
@@ -459,13 +459,28 @@ export default class CronService {
await fs.appendFile(absolutePath, data.toString());
});
cp.stderr.on('data', async (data) => {
this.logger.info(
'[panel][执行任务失败] 命令: %s, 错误信息: %j',
command,
data.toString(),
);
await fs.appendFile(absolutePath, data.toString());
});
cp.on('error', async (err) => {
this.logger.error(
'[panel][创建任务失败] 命令: %s, 错误信息: %j',
command,
err,
);
await fs.appendFile(absolutePath, JSON.stringify(err));
});
cp.on('exit', async (code) => {
this.logger.info(
'[panel][执行任务结束] 参数: %s, 退出码: %j',
JSON.stringify(params),
code,
);
await CrontabModel.update(
{ status: CrontabStatus.idle, pid: undefined },
{ where: { id } },