diff --git a/back/services/cron.ts b/back/services/cron.ts index 5644a227..08d943e1 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -225,7 +225,9 @@ export default class CronService { const str = err ? `\n${err}` : ''; fs.appendFileSync( `${doc.log_path}`, - `${str}\n## 执行结束... ${new Date().toLocaleString()} `, + `${str}\n## 执行结束... ${new Date() + .toLocaleString('zh', { hour12: false }) + .replace(' 24:', ' 00:')} `, ); } } @@ -305,6 +307,17 @@ export default class CronService { fs.appendFileSync(`${log_path}`, `${JSON.stringify(err)}`); } }); + + cp.on('exit', (code, signal) => { + this.logger.info( + `${command} pid: ${cp.pid} exit ${code} signal ${signal}`, + ); + this.cronDb.update( + { _id }, + { $set: { status: CrontabStatus.idle }, $unset: { pid: true } }, + ); + resolve(); + }); cp.on('close', (code) => { this.logger.info(`${command} pid: ${cp.pid} closed ${code}`); this.cronDb.update(