From bc2dcee05a4a4e925694d87c01a95aa6806f7cbe Mon Sep 17 00:00:00 2001 From: whyour Date: Tue, 11 May 2021 21:06:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=BA=E5=88=B6=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 5 ++++- src/pages/crontab/index.tsx | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index d9ac9003..f0f090cb 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -186,7 +186,10 @@ export default class CronService { cmd.on('exit', (code: number, signal: any) => { this.logger.silly(`cmd exit ${code}`); - this.cronDb.update({ _id }, { $set: { status: CrontabStatus.idle } }); + this.cronDb.update( + { _id }, + { $set: { status: CrontabStatus.idle }, $unset: { pid: true } }, + ); fs.appendFileSync(logFile, `\n\n执行结束...`); }); diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index 693d1e5a..0d9288d1 100644 --- a/src/pages/crontab/index.tsx +++ b/src/pages/crontab/index.tsx @@ -99,12 +99,12 @@ const Crontab = () => { align: 'center' as const, render: (text: string, record: any) => ( <> - {record.status === CrontabStatus.idle && ( + {record.status !== CrontabStatus.disabled && !record.pid && ( } color="default"> 空闲中 )} - {record.status === CrontabStatus.running && ( + {record.status === CrontabStatus.running && record.pid && ( } color="processing"> 运行中