From 17841acc451768341e35752d60a3bd140e2cd0e8 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:44:20 +1100 Subject: [PATCH] refactor(db): loop createConnectionPool until success --- src/database/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/database/index.ts b/src/database/index.ts index adec1cb..80c00b9 100644 --- a/src/database/index.ts +++ b/src/database/index.ts @@ -1,9 +1,15 @@ import { setDebug } from '../config'; -import { getPoolConnection } from './connection'; +import { sleep } from '../utils/sleep'; +import { createConnectionPool, isServerConnected } from './connection'; -setTimeout(() => { +setTimeout(async () => { setDebug(); - getPoolConnection(); + + while (!isServerConnected) { + await createConnectionPool(); + + if (!isServerConnected) await sleep(30000); + } }); setInterval(() => {