From 31812726190407ae52f673b9c3184f5348c2fcc1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 25 Oct 2023 17:53:49 +0300 Subject: add healthcheck public method, map by default to /healthz --- classes/Config.php | 4 +++- classes/Handler_Public.php | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/Config.php b/classes/Config.php index 72d6c5106..2c2cd4d65 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -643,7 +643,9 @@ class Config { } } - if (count($errors) > 0 && php_sapi_name() != "cli") { ?> + if (count($errors) > 0 && php_sapi_name() != "cli") { + http_response_code(503); ?> + diff --git a/classes/Handler_Public.php b/classes/Handler_Public.php index 8134eeff2..d0e434c8e 100644 --- a/classes/Handler_Public.php +++ b/classes/Handler_Public.php @@ -834,5 +834,11 @@ class Handler_Public extends Handler { exit; } + // implicit Config::sanity_check() does the actual checking */ + public function healthcheck() { + header("Content-Type: text/plain"); + print "OK"; + } + } ?> -- cgit v1.2.3