Browse Source

add task notify status

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

18
heroUnion.mjs

@ -56,6 +56,13 @@ class HeroUnion { @@ -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 { @@ -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 { @@ -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;

17
public/index.html

@ -73,6 +73,22 @@ @@ -73,6 +73,22 @@
</span>
</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>
<div class="stats heroStatus">
<span class="col">
@ -174,6 +190,7 @@ @@ -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);
});
};

Loading…
Cancel
Save