From 7f261df9a32b6b8f7b5a95256cca549a726416fc Mon Sep 17 00:00:00 2001 From: Pratap2018 Date: Mon, 25 Nov 2024 14:26:17 +0530 Subject: [PATCH] update connection settings --- src/main.ts | 13 ------------- src/mongoose/tenant-mongoose-connections.ts | 12 +++++++++++- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main.ts b/src/main.ts index 6384617d..02c6380f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -145,19 +145,6 @@ async function bootstrap() { `Server running on http://localhost:${process.env.PORT}`, 'Bootstrap', ); - setInterval(async () => await checkEdv(), 120000); -} - -async function checkEdv() { - try { - const resp = await fetch(process.env.EDV_BASE_URL + '/api'); - - if (resp.status == 200) { - process.env.EDV_STATUS = 'UP'; - } - } catch (error) { - process.env.EDV_STATUS = 'DOWN'; - } } bootstrap(); diff --git a/src/mongoose/tenant-mongoose-connections.ts b/src/mongoose/tenant-mongoose-connections.ts index 49e00635..d4b0eb3f 100644 --- a/src/mongoose/tenant-mongoose-connections.ts +++ b/src/mongoose/tenant-mongoose-connections.ts @@ -32,7 +32,17 @@ async function tenantConnection(tenantDB, uri) { if (!foundConn) { if (!connectionPromises[tenantDB]) { - connectionPromises[tenantDB] = mongoose.createConnection(uri).asPromise(); + connectionPromises[tenantDB] = mongoose + .createConnection(uri, { + maxConnecting: 10, + maxPoolSize: 100, + maxStalenessSeconds: 100, + maxIdleTimeMS: 500000, + serverSelectionTimeoutMS: 500000, + socketTimeoutMS: 500000, + connectTimeoutMS: 500000, + }) + .asPromise(); } const newConnection = await connectionPromises[tenantDB];