Commit df57b48a authored by Eriksson Monteiro's avatar Eriksson Monteiro

update node restart

parent 52a1074a
...@@ -33,14 +33,14 @@ class _API { ...@@ -33,14 +33,14 @@ class _API {
try { try {
return fetch(`${_API.HOST}`) return fetch(`${_API.HOST}`)
.then(response => { .then(response => {
if (this.apiHealthCheckFail >= 3) { if (this.apiHealthCheckFail >= 4) {
window.parent.postMessage({ type: 'node_restarted' }, 'tangled://millix-bar'); window.parent.postMessage({ type: 'node_restarted' }, 'tangled://millix-bar');
} }
this.apiHealthCheckFail = 0; this.apiHealthCheckFail = 0;
return response.json(); return response.json();
}).catch(e => { }).catch(e => {
this.apiHealthCheckFail++; this.apiHealthCheckFail++;
if (this.apiHealthCheckFail === 3) { if (this.apiHealthCheckFail === 4) {
window.parent.postMessage({ type: 'node_error' }, 'tangled://millix-bar'); window.parent.postMessage({ type: 'node_error' }, 'tangled://millix-bar');
} }
throw e; throw e;
...@@ -217,8 +217,8 @@ let apiCheckHandlerID = null; ...@@ -217,8 +217,8 @@ let apiCheckHandlerID = null;
function apiCheck() { function apiCheck() {
apiCheckHandlerID = true; apiCheckHandlerID = true;
API.apiHealthCheck() API.apiHealthCheck()
.then(() => apiCheckHandlerID = setTimeout(() => apiCheck(), 1000)) .then(() => apiCheckHandlerID = setTimeout(() => apiCheck(), 2500))
.catch(() => apiCheckHandlerID = setTimeout(() => apiCheck(), 1000)); .catch(() => apiCheckHandlerID = setTimeout(() => apiCheck(), 2500));
} }
window.addEventListener('message', ({ data }) => { window.addEventListener('message', ({ data }) => {
...@@ -269,11 +269,11 @@ window.addEventListener('message', ({ data }) => { ...@@ -269,11 +269,11 @@ window.addEventListener('message', ({ data }) => {
break; break;
case 'request_advertisement_payment': case 'request_advertisement_payment':
API.requestAdvertisementPayment(data.queue_id) API.requestAdvertisementPayment(data.queue_id)
.then(_=>_); .then(_ => _);
break; break;
case 'api_check': case 'api_check':
if (!apiCheckHandlerID) { if (!apiCheckHandlerID) {
apiCheck(); setTimeout(() => apiCheck(), 15000); // start api check after 15s
} }
break; 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