From d526602d1916935b648710a02e3d0122d092443a Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 26 Dec 2025 01:07:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=90=E8=A1=8C=E4=B8=AD?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=81=9C=E6=AD=A2=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index 95426dd8..94cdd95a 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -29,7 +29,7 @@ import { logStreamManager } from '../shared/logStreamManager'; @Service() export default class CronService { - constructor(@Inject('logger') private logger: winston.Logger) {} + constructor(@Inject('logger') private logger: winston.Logger) { } private isNodeCron(cron: Crontab) { const { schedule, extra_schedules } = cron; @@ -165,7 +165,7 @@ export default class CronService { let cron; try { cron = await this.getDb({ id }); - } catch (err) {} + } catch (err) { } if (!cron) { continue; } @@ -467,7 +467,10 @@ export default class CronService { for (const doc of docs) { // Kill all running instances of this task try { - const command = this.makeCommand(doc); + if (doc.pid) { + await killTask(doc.pid); + } + const command = doc.command.replace(/\s+/g, ' ').trim(); await killAllTasks(command); this.logger.info( `[panel][停止所有运行中的任务实例] 任务ID: ${doc.id}, 命令: ${command}`,