Skip to content

Commit c2acc62

Browse files
committed
Don't kill program if can't connect to read server
1 parent 176f2ce commit c2acc62

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/databases/Postgres.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,23 @@ export class Postgres implements IDatabase {
5353
});
5454

5555
if (this.config.postgresReadOnly && this.config.postgresReadOnly.enabled) {
56-
this.poolRead = new Pool({
57-
...this.config.postgresReadOnly
58-
});
59-
this.poolRead.on("error", (err, client) => {
60-
Logger.error(err.stack);
61-
this.lastPoolReadFail = Date.now();
62-
63-
try {
64-
client.release(true);
65-
} catch (err) {
66-
Logger.error(`poolRead (postgres): ${err}`);
67-
}
68-
});
56+
try {
57+
this.poolRead = new Pool({
58+
...this.config.postgresReadOnly
59+
});
60+
this.poolRead.on("error", (err, client) => {
61+
Logger.error(err.stack);
62+
this.lastPoolReadFail = Date.now();
63+
64+
try {
65+
client.release(true);
66+
} catch (err) {
67+
Logger.error(`poolRead (postgres): ${err}`);
68+
}
69+
});
70+
} catch (e) {
71+
Logger.error(`poolRead (postgres): ${e}`);
72+
}
6973
}
7074

7175
if (!this.config.readOnly) {

0 commit comments

Comments
 (0)