From 43d5063293341e55fdcf6f5cfa542d4e5726a4dc Mon Sep 17 00:00:00 2001 From: whyour Date: Tue, 4 May 2021 12:10:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dschedule=E8=BF=9B=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/schedule.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/back/schedule.ts b/back/schedule.ts index 07ff6bbd..6cb4f6e6 100644 --- a/back/schedule.ts +++ b/back/schedule.ts @@ -1,10 +1,13 @@ import schedule from 'node-schedule'; +import express from 'express'; import { exec } from 'child_process'; import Logger from './loaders/logger'; import { Container } from 'typedi'; import CronService from './services/cron'; import { CrontabStatus } from './data/cron'; +const app = express(); + const run = async () => { const cronService = Container.get(CronService); const cronDb = cronService.getDb(); @@ -36,9 +39,16 @@ const run = async () => { }); }; -run(); -Logger.info(` - ################################################ - 🛡️ 定时任务schedule启动成功 🛡️ - ################################################ -`); +app + .listen(5800, () => { + run(); + Logger.info(` + ################################################ + 🛡️ Schedule listening on port: 5800 🛡️ + ################################################ + `); + }) + .on('error', (err) => { + Logger.error(err); + process.exit(1); + });