|
|
|
@ -271,12 +271,12 @@ class HeroUnion {
@@ -271,12 +271,12 @@ class HeroUnion {
|
|
|
|
|
if (response.status == 200) { |
|
|
|
|
notified = true; |
|
|
|
|
}else { |
|
|
|
|
console.error('[FAILED] Notify to %s failed, response status: %s, status text: %s, result: %s', |
|
|
|
|
common.error('[FAILED] Notify to %s failed, response status: %s, status text: %s, result: %s', |
|
|
|
|
notify_url, response.status, response.statusText, response.data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch(err) { |
|
|
|
|
console.error('[ERROR] Notify to %s failed: %s', notify_url, err); |
|
|
|
|
common.error('[ERROR] Notify to %s failed: %s', notify_url, err); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return notified; |
|
|
|
@ -301,14 +301,14 @@ class HeroUnion {
@@ -301,14 +301,14 @@ class HeroUnion {
|
|
|
|
|
|
|
|
|
|
if (cachedBot) { //如果是已经存在的爬虫
|
|
|
|
|
if (cachedBot.status != bot.status) { |
|
|
|
|
console.log('Hero %s status change from %s to %s', cachedBot.name, cachedBot.status, bot.status); |
|
|
|
|
common.log('Hero %s status change from %s to %s', cachedBot.name, cachedBot.status, bot.status); |
|
|
|
|
this.heroStatus[cachedBot.status] --; |
|
|
|
|
this.heroStatus[bot.status] ++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.heros[cachedBotIndex] = bot; //数据更新
|
|
|
|
|
|
|
|
|
|
console.log('Hero %s is %s at %s', bot.name, bot.status, bot.timestamp); |
|
|
|
|
common.log('Hero %s is %s at %s', bot.name, bot.status, bot.timestamp); |
|
|
|
|
}else { |
|
|
|
|
this.heros.push(bot); //添加新爬虫
|
|
|
|
|
|
|
|
|
@ -319,7 +319,7 @@ class HeroUnion {
@@ -319,7 +319,7 @@ class HeroUnion {
|
|
|
|
|
this.heroStatus.busy ++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('Hero %s is onboard at %s', bot.name, bot.timestamp); |
|
|
|
|
common.log('Hero %s is onboard at %s', bot.name, bot.timestamp); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -338,7 +338,7 @@ class HeroUnion {
@@ -338,7 +338,7 @@ class HeroUnion {
|
|
|
|
|
|
|
|
|
|
_self.heros[index].status = 'offline'; |
|
|
|
|
_self.heroStatus.offline ++; |
|
|
|
|
console.log('Hero %s is offline, last heart beat at %s', item.name, item.timestamp); |
|
|
|
|
common.log('Hero %s is offline, last heart beat at %s', item.name, item.timestamp); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, { |
|
|
|
@ -346,7 +346,7 @@ class HeroUnion {
@@ -346,7 +346,7 @@ class HeroUnion {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
cronjob.start(); |
|
|
|
|
console.log('Cronjob of hero heart check started.'); |
|
|
|
|
common.log('Cronjob of hero heart check started.'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//自动重新加载配置文件
|
|
|
|
@ -363,7 +363,7 @@ class HeroUnion {
@@ -363,7 +363,7 @@ class HeroUnion {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
cronjob.start(); |
|
|
|
|
console.log('Cronjob of config auto reload started.'); |
|
|
|
|
common.log('Cronjob of config auto reload started.'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取联盟状态
|
|
|
|
|