From 19cfc9e351fa135ee601306754ef847e039a4e0d Mon Sep 17 00:00:00 2001 From: whyour Date: Mon, 26 Aug 2024 23:05:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E8=BF=90=E8=A1=8C=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/shared/pLimit.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/back/shared/pLimit.ts b/back/shared/pLimit.ts index d6550613..af0dd7c6 100644 --- a/back/shared/pLimit.ts +++ b/back/shared/pLimit.ts @@ -123,12 +123,15 @@ class TaskLimit { let runs = this.queuedCrons.get(cron.id); const result = runs?.length ? [...runs, fn] : [fn]; const repeatTimes = this.repeatCronNotifyMap.get(cron.id) || 0; - if (result?.length > 5 && repeatTimes < 3) { - this.repeatCronNotifyMap.set(cron.id, repeatTimes + 1); - this.notificationService.externalNotify( - '任务重复运行', - `任务:${cron.name},命令:${cron.command},定时:${cron.schedule},处于运行中的超过 5 个,请检查定时设置`, - ); + if (result?.length > 5) { + if (repeatTimes < 3) { + this.repeatCronNotifyMap.set(cron.id, repeatTimes + 1); + this.notificationService.externalNotify( + '任务重复运行', + `任务:${cron.name},命令:${cron.command},定时:${cron.schedule},处于运行中的超过 5 个,请检查定时设置`, + ); + } + Logger.warn(`[schedule][任务重复运行] 参数 ${JSON.stringify(cron)}`); return; } this.queuedCrons.set(cron.id, result);