From 7e8e4b1e6c89488db3806bb2fc7a7d3d09d79530 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Fri, 13 May 2022 11:54:52 +0200 Subject: [PATCH] If bisq data folder is not ready, retry every 3 minutes instead of exit --- backend/src/api/bisq/bisq.ts | 12 +++++++++--- backend/src/api/bisq/markets.ts | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/backend/src/api/bisq/bisq.ts b/backend/src/api/bisq/bisq.ts index 138384c8b..f16356d1c 100644 --- a/backend/src/api/bisq/bisq.ts +++ b/backend/src/api/bisq/bisq.ts @@ -35,7 +35,13 @@ class Bisq { constructor() {} startBisqService(): void { - this.checkForBisqDataFolder(); + try { + this.checkForBisqDataFolder(); + } catch (e) { + logger.info('Retrying to start bisq service in 3 minutes'); + setTimeout(this.startBisqService.bind(this), 180000); + return; + } this.loadBisqDumpFile(); setInterval(this.updatePrice.bind(this), 1000 * 60 * 60); this.updatePrice(); @@ -90,7 +96,7 @@ class Bisq { private checkForBisqDataFolder() { if (!fs.existsSync(Bisq.BLOCKS_JSON_FILE_PATH)) { logger.warn(Bisq.BLOCKS_JSON_FILE_PATH + ` doesn't exist. Make sure Bisq is running and the config is correct before starting the server.`); - return process.exit(1); + throw new Error(`Cannot load BISQ ${Bisq.BLOCKS_JSON_FILE_PATH} file`); } } @@ -162,7 +168,7 @@ class Bisq { this.buildIndex(); this.calculateStats(); } catch (e) { - logger.info('loadBisqDumpFile() error.' + (e instanceof Error ? e.message : e)); + logger.info('Cannot load bisq dump file because: ' + (e instanceof Error ? e.message : e)); } } diff --git a/backend/src/api/bisq/markets.ts b/backend/src/api/bisq/markets.ts index 765063a43..08f40d772 100644 --- a/backend/src/api/bisq/markets.ts +++ b/backend/src/api/bisq/markets.ts @@ -26,7 +26,13 @@ class Bisq { constructor() {} startBisqService(): void { - this.checkForBisqDataFolder(); + try { + this.checkForBisqDataFolder(); + } catch (e) { + logger.info('Retrying to start bisq service (markets) in 3 minutes'); + setTimeout(this.startBisqService.bind(this), 180000); + return; + } this.loadBisqDumpFile(); this.startBisqDirectoryWatcher(); } @@ -34,7 +40,7 @@ class Bisq { private checkForBisqDataFolder() { if (!fs.existsSync(Bisq.MARKET_JSON_PATH + Bisq.MARKET_JSON_FILE_PATHS.cryptoCurrency)) { logger.err(Bisq.MARKET_JSON_PATH + Bisq.MARKET_JSON_FILE_PATHS.cryptoCurrency + ` doesn't exist. Make sure Bisq is running and the config is correct before starting the server.`); - return process.exit(1); + throw new Error(`Cannot load BISQ ${Bisq.MARKET_JSON_FILE_PATHS.cryptoCurrency} file`); } }