Don't kill program if can't connect to read server

This commit is contained in:
Ajay
2022-10-27 01:31:41 -04:00
parent 176f2ce7b9
commit c2acc6227b

View File

@@ -53,19 +53,23 @@ export class Postgres implements IDatabase {
}); });
if (this.config.postgresReadOnly && this.config.postgresReadOnly.enabled) { if (this.config.postgresReadOnly && this.config.postgresReadOnly.enabled) {
this.poolRead = new Pool({ try {
...this.config.postgresReadOnly this.poolRead = new Pool({
}); ...this.config.postgresReadOnly
this.poolRead.on("error", (err, client) => { });
Logger.error(err.stack); this.poolRead.on("error", (err, client) => {
this.lastPoolReadFail = Date.now(); Logger.error(err.stack);
this.lastPoolReadFail = Date.now();
try { try {
client.release(true); client.release(true);
} catch (err) { } catch (err) {
Logger.error(`poolRead (postgres): ${err}`); Logger.error(`poolRead (postgres): ${err}`);
} }
}); });
} catch (e) {
Logger.error(`poolRead (postgres): ${e}`);
}
} }
if (!this.config.readOnly) { if (!this.config.readOnly) {