Skip to content

Commit

Permalink
update connection settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratap2018 committed Nov 25, 2024
1 parent 5b806d8 commit 7f261df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
13 changes: 0 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
12 changes: 11 additions & 1 deletion src/mongoose/tenant-mongoose-connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 7f261df

Please sign in to comment.