From 8619f266283ba7ed6d5f6be93eb522f42646da92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 19 Feb 2024 14:50:57 +0000 Subject: [PATCH] Introduce env var --- app/controllers/api/health.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 3316b9f087..6049b1c456 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -56,7 +56,10 @@ App::get('/v1/health/version') ->action(function (mixed $http, Response $response) { $stats = $http->stats(); - if (($stats['idle_worker_num'] ?? 0) <= 1) { + $idleWorkers = $stats['idle_worker_num'] ?? 0; + $minIdleWorkers = \intval(App::getEnv('_APP_HEALTHCHECK_MIN_IDLE_WORKERS', '2')); + + if ($idleWorkers < $minIdleWorkers) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Can not process more requests at the moment.'); }