Browse Source

add task notify status

master
filesite 7 months ago
parent
commit
d586a2d144
  1. 18
      heroUnion.mjs
  2. 17
      public/index.html

18
heroUnion.mjs

@ -56,6 +56,13 @@ class HeroUnion {
'failed': 0 'failed': 0
}; };
//任务通知回调相关数据
this.taskNotifyStatus = {
'total': 0,
'done': 0,
'failed': 0
};
this.statusCode = { this.statusCode = {
'waiting': '待处理', 'waiting': '待处理',
'running': '处理中', 'running': '处理中',
@ -347,6 +354,16 @@ class HeroUnion {
this.tasks[taskIndex].notify_time ++; 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; return notified;
} }
@ -494,6 +511,7 @@ class HeroUnion {
//获取联盟状态 //获取联盟状态
getStats() { getStats() {
this.stats.taskStatus = this.taskStatus; this.stats.taskStatus = this.taskStatus;
this.stats.taskNotifyStatus = this.taskNotifyStatus;
this.stats.heroStatus = this.heroStatus; this.stats.heroStatus = this.heroStatus;
this.stats.run_seconds = common.getTimestampInSeconds() - this.stats.start_time; this.stats.run_seconds = common.getTimestampInSeconds() - this.stats.start_time;

17
public/index.html

@ -73,6 +73,22 @@
</span> </span>
</div> </div>
<h4 class="mt-d5">任务通知状态(最近 24 小时)</h4>
<div class="stats taskNotifyStatus">
<span class="col">
<strong class="total">...</strong>
<label>总数</label>
</span>
<span class="col success">
<strong class="done">...</strong>
<label>完成</label>
</span>
<span class="col danger">
<strong class="failed">...</strong>
<label>失败</label>
</span>
</div>
<h4 class="mt-d5">爬虫状态</h4> <h4 class="mt-d5">爬虫状态</h4>
<div class="stats heroStatus"> <div class="stats heroStatus">
<span class="col"> <span class="col">
@ -174,6 +190,7 @@
$('#herounion_stats').text(JSON.stringify(data, null, 4)); $('#herounion_stats').text(JSON.stringify(data, null, 4));
$('.run_time').text( formatSeconds(data.run_seconds) ); $('.run_time').text( formatSeconds(data.run_seconds) );
renderStats('taskStatus', data.taskStatus); renderStats('taskStatus', data.taskStatus);
renderStats('taskNotifyStatus', data.taskNotifyStatus);
renderStats('heroStatus', data.heroStatus); renderStats('heroStatus', data.heroStatus);
}); });
}; };

Loading…
Cancel
Save