When LN backend crashed, catch the error and restart after 1 minute

This commit is contained in:
nymkappa 2022-08-03 12:43:41 +02:00
parent 6be2985b40
commit 99379d53bf
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04

View File

@ -137,9 +137,7 @@ class Server {
}
if (config.LIGHTNING.ENABLED) {
fundingTxFetcher.$init()
.then(() => networkSyncService.$startService())
.then(() => lightningStatsUpdater.$startService());
this.$runLightningBackend();
}
this.server.listen(config.MEMPOOL.HTTP_PORT, () => {
@ -185,6 +183,18 @@ class Server {
}
}
async $runLightningBackend() {
try {
await fundingTxFetcher.$init();
await networkSyncService.$startService();
await lightningStatsUpdater.$startService();
} catch(e) {
logger.err(`Lightning backend crashed. Restarting in 1 minute. Reason: ${(e instanceof Error ? e.message : e)}`);
await Common.sleep$(1000 * 60);
this.$runLightningBackend();
};
}
setUpWebsocketHandling() {
if (this.wss) {
websocketHandler.setWebsocketServer(this.wss);