#!/command/with-contenv sh
curl_options="--fail --location --insecure --silent --show-error --output /dev/null"
healthcheck_url="http://localhost:8080${HEALTHCHECK_PATH}"

is_online() {
    curl $curl_options "$healthcheck_url"
}

if is_online; then
    echo "✅ NGINX + PHP-FPM is running correctly."
    exit 0
else
    echo "❌ There seems to be a failure in checking the NGINX + PHP-FPM."
    status_code=$(curl $curl_options -w "%{http_code}" "$healthcheck_url")
    echo "HTTP Status Code: $status_code"
    exit 1
fi
