mirror of
https://github.com/minio/minio.git
synced 2025-11-07 04:42:56 -05:00
Add healthcheck endpoints (#5543)
This PR adds readiness and liveness endpoints to probe Minio server instance health. Endpoints can only be accessed without authentication and the paths are /minio/health/live and /minio/health/ready for liveness and readiness respectively. The new healthcheck liveness endpoint is used for Docker healthcheck now. Fixes #5357 Fixes #5514
This commit is contained in:
@@ -20,7 +20,7 @@ set -x
|
||||
_init () {
|
||||
scheme="http://"
|
||||
address="$(netstat -nplt 2>/dev/null | awk ' /(.*\/minio)/ { gsub(":::","127.0.0.1:",$4); print $4}')"
|
||||
resource="/minio/index.html"
|
||||
resource="/minio/health/live"
|
||||
start=$(stat -c "%Y" /proc/1)
|
||||
}
|
||||
|
||||
@@ -34,11 +34,10 @@ healthcheck_main () {
|
||||
exit 0
|
||||
else
|
||||
# Get the http response code
|
||||
http_response=$(curl -H "User-Agent: Mozilla" -s -k -o /dev/null -I -w "%{http_code}" \
|
||||
${scheme}${address}${resource})
|
||||
http_response=$(curl -s -k -o /dev/null -I -w "%{http_code}" ${scheme}${address}${resource})
|
||||
|
||||
# Get the http response body
|
||||
http_response_body=$(curl -H "User-Agent: Mozilla" -k -s ${scheme}${address}${resource})
|
||||
http_response_body=$(curl -k -s ${scheme}${address}${resource})
|
||||
|
||||
# server returns response 403 and body "SSL required" if non-TLS
|
||||
# connection is attempted on a TLS-configured server. Change
|
||||
@@ -46,14 +45,11 @@ healthcheck_main () {
|
||||
if [ "$http_response" = "403" ] && \
|
||||
[ "$http_response_body" = "SSL required" ]; then
|
||||
scheme="https://"
|
||||
http_response=$(curl -H "User-Agent: Mozilla" -s -k -o /dev/null -I -w "%{http_code}" \
|
||||
${scheme}${address}${resource})
|
||||
http_response=$(curl -s -k -o /dev/null -I -w "%{http_code}" ${scheme}${address}${resource})
|
||||
fi
|
||||
|
||||
# If http_repsonse is 200 - server is up. When MINIO_BROWSER is
|
||||
# set to off, curl responds with 404. We assume that the server
|
||||
# is up
|
||||
[ "$http_response" = "200" ] || [ "$http_response" = "404" ]
|
||||
# If http_repsonse is 200 - server is up.
|
||||
[ "$http_response" = "200" ]
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user