Browse Source

change frequence of cronjobs

master
filesite 8 months ago
parent
commit
0c9e9ca5a7
  1. 4
      lib/taskMoniter.mjs
  2. 4
      spider.mjs

4
lib/taskMoniter.mjs

@ -19,7 +19,7 @@ import HeroBot from "./heroBot.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 { @@ -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());
}, {

4
spider.mjs

@ -101,8 +101,8 @@ import cron from 'node-cron'; @@ -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);

Loading…
Cancel
Save