Browse Source

change cronjobs frequence

master
filesite 8 months ago
parent
commit
b40dff4044
  1. 8
      conf/config.json
  2. 16
      heroUnion.mjs

8
conf/config.json

@ -9,10 +9,10 @@
"notify_timeout": 8, "notify_timeout": 8,
"notify_max_try": 5, "notify_max_try": 5,
"reloadConfigFrequence": 60, "reloadConfigFrequence": 1,
"heroHeartCheckFrequence": 60, "heroHeartCheckFrequence": 1,
"autoCleanTaskFrequence": 300, "autoCleanTaskFrequence": 5,
"autoNotifyTaskFrequence": 20, "autoNotifyTaskFrequence": 1,
"max_list_hero_num": 1000, "max_list_hero_num": 1000,

16
heroUnion.mjs

@ -399,8 +399,8 @@ class HeroUnion {
let _self = this; let _self = this;
const frequence = typeof(this.config.heroHeartCheckFrequence) != 'undefined' const frequence = typeof(this.config.heroHeartCheckFrequence) != 'undefined'
&& this.config.heroHeartCheckFrequence ? this.config.heroHeartCheckFrequence : 60; //1 分钟检查一次 && this.config.heroHeartCheckFrequence ? this.config.heroHeartCheckFrequence : 1; //1 分钟检查一次
const cronjob = cron.schedule(`*/${frequence} * * * * *`, () => { const cronjob = cron.schedule(`*/${frequence} * * * *`, () => {
let timestamp = common.getTimestampInSeconds(); let timestamp = common.getTimestampInSeconds();
_self.heros.forEach(function(item, index) { _self.heros.forEach(function(item, index) {
if (item.status != 'offline' && timestamp - item.timestamp > _self.heroHeartTimeout) { if (item.status != 'offline' && timestamp - item.timestamp > _self.heroHeartTimeout) {
@ -424,8 +424,8 @@ class HeroUnion {
let _self = this; let _self = this;
const frequence = typeof(this.config.reloadConfigFrequence) != 'undefined' const frequence = typeof(this.config.reloadConfigFrequence) != 'undefined'
&& this.config.reloadConfigFrequence ? this.config.reloadConfigFrequence : 300; //5 分钟重新加载一次 && this.config.reloadConfigFrequence ? this.config.reloadConfigFrequence : 5; //5 分钟重新加载一次
const cronjob = cron.schedule(`*/${frequence} * * * * *`, () => { const cronjob = cron.schedule(`*/${frequence} * * * *`, () => {
const forceReload = true; const forceReload = true;
_self.getConfig(forceReload); _self.getConfig(forceReload);
}, { }, {
@ -441,8 +441,8 @@ class HeroUnion {
let _self = this; let _self = this;
const frequence = typeof(this.config.autoCleanTaskFrequence) != 'undefined' const frequence = typeof(this.config.autoCleanTaskFrequence) != 'undefined'
&& this.config.autoCleanTaskFrequence ? this.config.autoCleanTaskFrequence : 600; //10 分钟检查一次 && this.config.autoCleanTaskFrequence ? this.config.autoCleanTaskFrequence : 10; //10 分钟检查一次
const cronjob = cron.schedule(`*/${frequence} * * * * *`, () => { const cronjob = cron.schedule(`*/${frequence} * * * *`, () => {
let timestamp = common.getTimestampInSeconds(); let timestamp = common.getTimestampInSeconds();
let tasksLeft = _self.tasks.reduce(function(accumulator, item) { let tasksLeft = _self.tasks.reduce(function(accumulator, item) {
@ -476,8 +476,8 @@ class HeroUnion {
let _self = this; let _self = this;
const frequence = typeof(this.config.autoNotifyTaskFrequence) != 'undefined' const frequence = typeof(this.config.autoNotifyTaskFrequence) != 'undefined'
&& this.config.autoNotifyTaskFrequence ? this.config.autoNotifyTaskFrequence : 120; //2 分钟检查一次 && this.config.autoNotifyTaskFrequence ? this.config.autoNotifyTaskFrequence : 2; //2 分钟检查一次
const cronjob = cron.schedule(`*/${frequence} * * * * *`, () => { const cronjob = cron.schedule(`*/${frequence} * * * *`, () => {
let task = _self.tasks.find((item) => item.status == 'done' && item.notified == false && item.notify_time < _self.notify_max_try); let task = _self.tasks.find((item) => item.status == 'done' && item.notified == false && item.notify_time < _self.notify_max_try);
if (task) { if (task) {
_self.handleTaskDone(task); _self.handleTaskDone(task);

Loading…
Cancel
Save