From 8043bd9006e620852453acae82e9c634ce1e8a58 Mon Sep 17 00:00:00 2001 From: Ajay Date: Sat, 20 Apr 2024 00:02:15 -0400 Subject: [PATCH] Make max response time configurable --- src/config.ts | 3 ++- src/routes/getReady.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config.ts b/src/config.ts index 3752323..a490aac 100644 --- a/src/config.ts +++ b/src/config.ts @@ -193,7 +193,8 @@ addDefaults(config, { minUserIDLength: 30, deArrowPaywall: false, useCacheForSegmentGroups: false, - maxConnections: 100 + maxConnections: 100, + maxResponseTime: 1000 }); loadFromEnv(config); migrate(config); diff --git a/src/routes/getReady.ts b/src/routes/getReady.ts index 02a6b0c..6611e69 100644 --- a/src/routes/getReady.ts +++ b/src/routes/getReady.ts @@ -14,9 +14,9 @@ export async function getReady(req: Request, res: Response, server: Server): Pro if (!connections || (connections < config.maxConnections && (!config.redis || redisStats.activeRequests < config.redis.maxConnections * 0.8) - && (!config.redis || redisStats.avgReadTime < 2000 || redisStats.activeRequests < 1) + && (!config.redis || redisStats.avgReadTime < config.maxResponseTime || redisStats.activeRequests < 1) && (!config.postgres || postgresStats.activeRequests < config.postgres.maxActiveRequests * 0.8)) - && (!config.postgres || postgresStats.avgReadTime < 2000)) { + && (!config.postgres || postgresStats.avgReadTime < config.maxResponseTime)) { return res.sendStatus(200); } else { return res.sendStatus(500);