add healthcheck public method, map by default to /healthz

This commit is contained in:
Andrew Dolgov 2023-10-25 17:53:49 +03:00
parent 865ecc8796
commit 3181272619
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
3 changed files with 11 additions and 1 deletions

View File

@ -34,6 +34,8 @@ http {
internal;
}
rewrite ${APP_BASE}/healthz ${APP_BASE}/public.php?op=healthcheck;
location ~ \.php$ {
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+?\.php)(/.*)$;

View File

@ -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); ?>
<!DOCTYPE html>
<html>
<head>

View File

@ -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";
}
}
?>