From 0c9e9ca5a7d6563560671403936f9cce7717c189 Mon Sep 17 00:00:00 2001 From: filesite Date: Sat, 13 Apr 2024 10:18:05 +0800 Subject: [PATCH] change frequence of cronjobs --- lib/taskMoniter.mjs | 4 ++-- spider.mjs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/taskMoniter.mjs b/lib/taskMoniter.mjs index f837a73..7245191 100644 --- a/lib/taskMoniter.mjs +++ b/lib/taskMoniter.mjs @@ -19,7 +19,7 @@ import HeroBot from "./heroBot.mjs"; class TaskMoniter { constructor(task_list_dir) { - this.check_time_gap = 60; //检测间隔时间,单位:秒 + this.check_time_gap = 1; //检测间隔时间,单位:分钟 this.checking = false; this.task_dir = task_list_dir; //监控目录:任务列表保存目录 @@ -197,7 +197,7 @@ class TaskMoniter { //auto check new tasks const _self = this; const task_check_time = this.check_time_gap; - const task_auto_run = cron.schedule(`*/${task_check_time} * * * * *`, async () => { + const task_auto_run = cron.schedule(`*/${task_check_time} * * * *`, async () => { await _self.checkTasks(); console.log('Status', _self.getStatus()); }, { diff --git a/spider.mjs b/spider.mjs index 5e299d8..ab999eb 100644 --- a/spider.mjs +++ b/spider.mjs @@ -101,8 +101,8 @@ import cron from 'node-cron'; ); //爬虫心跳上报 - const heartBeatFrequence = 300; //5 分钟上报一次 - const heroUnionHeartBeat = cron.schedule(`*/${heartBeatFrequence} * * * * *`, async () => { + const heartBeatFrequence = 5; //5 分钟上报一次 + const heroUnionHeartBeat = cron.schedule(`*/${heartBeatFrequence} * * * *`, async () => { let status = spider_is_running ? 'busy' : 'idle'; const res = await heroBot.heartBeat(status); console.log('HeroUnion bot heart beat result', res);