diff --git a/heroUnion.mjs b/heroUnion.mjs index cd51c5e..d955927 100644 --- a/heroUnion.mjs +++ b/heroUnion.mjs @@ -56,6 +56,13 @@ class HeroUnion { 'failed': 0 }; + //任务通知回调相关数据 + this.taskNotifyStatus = { + 'total': 0, + 'done': 0, + 'failed': 0 + }; + this.statusCode = { 'waiting': '待处理', 'running': '处理中', @@ -347,6 +354,16 @@ class HeroUnion { this.tasks[taskIndex].notify_time ++; } + //更新任务通知状态数据 + if (notified) { + this.taskNotifyStatus.total ++; + this.taskNotifyStatus.done ++; + }else if (!notified && this.tasks[taskIndex].notify_time == this.notify_max_try) { + this.taskNotifyStatus.total ++; + this.taskNotifyStatus.failed ++; + common.error('[FAILED] Finally failed after %s try, notify to %s', this.notify_max_try, notify_url); + } + return notified; } @@ -494,6 +511,7 @@ class HeroUnion { //获取联盟状态 getStats() { this.stats.taskStatus = this.taskStatus; + this.stats.taskNotifyStatus = this.taskNotifyStatus; this.stats.heroStatus = this.heroStatus; this.stats.run_seconds = common.getTimestampInSeconds() - this.stats.start_time; diff --git a/public/index.html b/public/index.html index b90a9c2..d0995c7 100644 --- a/public/index.html +++ b/public/index.html @@ -73,6 +73,22 @@ +

任务通知状态(最近 24 小时)

+
+ + ... + + + + ... + + + + ... + + +
+

爬虫状态

@@ -174,6 +190,7 @@ $('#herounion_stats').text(JSON.stringify(data, null, 4)); $('.run_time').text( formatSeconds(data.run_seconds) ); renderStats('taskStatus', data.taskStatus); + renderStats('taskNotifyStatus', data.taskNotifyStatus); renderStats('heroStatus', data.heroStatus); }); };