don't ping worker for more than 2 minutes

This commit is contained in:
Michal Moskal 2015-04-23 10:39:30 -07:00
Родитель 8c3a78f3e3
Коммит fbe2c0cbc8
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -1417,7 +1417,13 @@ class Worker {
debug.log(d.replace(/\n$/, ""))
})
var numPing = 0
var ping = () => {
if (++numPing > 120) {
error.log("cannot start worker, #pings " + numPing)
return
}
var u = this.getUrl()
u.path = "/-tdevmgmt-/" + config.deploymentKey + "/ready"
var creq = http.request(u, cres => {
@ -1433,7 +1439,8 @@ class Worker {
}
})
creq.on("error", err => {
debug.log("ping failed, " + err.message)
if (err.code == 'ECONNREFUSED') {}
else debug.log("ping failed, " + err.message)
setTimeout(ping, 1000)
})
creq.end()