If bisq data folder is not ready, retry every 3 minutes instead of exit

This commit is contained in:
nymkappa 2022-05-13 11:54:52 +02:00
parent e63aaedbc0
commit 7e8e4b1e6c
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 17 additions and 5 deletions

View File

@ -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));
}
}

View File

@ -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`);
}
}