Commit df57b48a authored by Eriksson Monteiro's avatar Eriksson Monteiro

update node restart

parent 52a1074a
......@@ -33,14 +33,14 @@ class _API {
try {
return fetch(`${_API.HOST}`)
.then(response => {
if (this.apiHealthCheckFail >= 3) {
if (this.apiHealthCheckFail >= 4) {
window.parent.postMessage({ type: 'node_restarted' }, 'tangled://millix-bar');
}
this.apiHealthCheckFail = 0;
return response.json();
}).catch(e => {
this.apiHealthCheckFail++;
if (this.apiHealthCheckFail === 3) {
if (this.apiHealthCheckFail === 4) {
window.parent.postMessage({ type: 'node_error' }, 'tangled://millix-bar');
}
throw e;
......@@ -217,8 +217,8 @@ let apiCheckHandlerID = null;
function apiCheck() {
apiCheckHandlerID = true;
API.apiHealthCheck()
.then(() => apiCheckHandlerID = setTimeout(() => apiCheck(), 1000))
.catch(() => apiCheckHandlerID = setTimeout(() => apiCheck(), 1000));
.then(() => apiCheckHandlerID = setTimeout(() => apiCheck(), 2500))
.catch(() => apiCheckHandlerID = setTimeout(() => apiCheck(), 2500));
}
window.addEventListener('message', ({ data }) => {
......@@ -269,11 +269,11 @@ window.addEventListener('message', ({ data }) => {
break;
case 'request_advertisement_payment':
API.requestAdvertisementPayment(data.queue_id)
.then(_=>_);
.then(_ => _);
break;
case 'api_check':
if (!apiCheckHandlerID) {
apiCheck();
setTimeout(() => apiCheck(), 15000); // start api check after 15s
}
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment