Only log warning if main update loop has failed more than once.
This commit is contained in:
parent
c6d0571be8
commit
b4a17693af
@ -83,7 +83,7 @@ class Server {
|
|||||||
|
|
||||||
this.setUpHttpApiRoutes();
|
this.setUpHttpApiRoutes();
|
||||||
this.setUpWebsocketHandling();
|
this.setUpWebsocketHandling();
|
||||||
this.runMempoolIntervalFunctions();
|
this.runMainUpdateLoop();
|
||||||
|
|
||||||
fiatConversion.startService();
|
fiatConversion.startService();
|
||||||
diskCache.loadMempoolCache();
|
diskCache.loadMempoolCache();
|
||||||
@ -107,16 +107,21 @@ class Server {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async runMempoolIntervalFunctions() {
|
async runMainUpdateLoop() {
|
||||||
try {
|
try {
|
||||||
await memPool.$updateMemPoolInfo();
|
await memPool.$updateMemPoolInfo();
|
||||||
await blocks.$updateBlocks();
|
await blocks.$updateBlocks();
|
||||||
await memPool.$updateMempool();
|
await memPool.$updateMempool();
|
||||||
setTimeout(this.runMempoolIntervalFunctions.bind(this), config.ELECTRS.POLL_RATE_MS);
|
setTimeout(this.runMainUpdateLoop.bind(this), config.ELECTRS.POLL_RATE_MS);
|
||||||
this.retryOnElectrsErrorAfterSeconds = 5;
|
this.retryOnElectrsErrorAfterSeconds = 5;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn(`runMempoolIntervalFunctions error: ${(e.message || e)}. Retrying in ${this.retryOnElectrsErrorAfterSeconds} sec.`);
|
const loggerMsg = `runMainLoop error: ${(e.message || e)}. Retrying in ${this.retryOnElectrsErrorAfterSeconds} sec.`;
|
||||||
setTimeout(this.runMempoolIntervalFunctions.bind(this), 1000 * this.retryOnElectrsErrorAfterSeconds);
|
if (this.retryOnElectrsErrorAfterSeconds > 5) {
|
||||||
|
logger.warn(loggerMsg);
|
||||||
|
} else {
|
||||||
|
logger.debug(loggerMsg);
|
||||||
|
}
|
||||||
|
setTimeout(this.runMainUpdateLoop.bind(this), 1000 * this.retryOnElectrsErrorAfterSeconds);
|
||||||
this.retryOnElectrsErrorAfterSeconds *= 2;
|
this.retryOnElectrsErrorAfterSeconds *= 2;
|
||||||
this.retryOnElectrsErrorAfterSeconds = Math.min(this.retryOnElectrsErrorAfterSeconds, 60);
|
this.retryOnElectrsErrorAfterSeconds = Math.min(this.retryOnElectrsErrorAfterSeconds, 60);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user