From 56900d37acff1dfeb2368fa70345467473a68103 Mon Sep 17 00:00:00 2001 From: progprnv <145828371+progprnv@users.noreply.github.com> Date: Thu, 6 Feb 2025 16:31:42 +0530 Subject: [PATCH] chore: improve health check script (#4596) Consider capturing and returning the exit status from `curlCheck()` rather than `exit 1` inside the function --- healthcheck.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/healthcheck.sh b/healthcheck.sh index c9507689..9b29906b 100644 --- a/healthcheck.sh +++ b/healthcheck.sh @@ -1,18 +1,17 @@ -#!/bin/sh - curlCheck() { if ! curl -s --head "$1" | head -n 1 | grep -q "HTTP/1.[01] [23].."; then echo "URL request failed!" - exit 1 + return 1 else echo "URL request succeeded!" + return 0 fi } if [ "$ENABLE_SUBPATH_BASED_ACCESS" = "true" ]; then - curlCheck "http://localhost:80/backend/ping" + curlCheck "http://localhost:80/backend/ping" || exit 1 else - curlCheck "http://localhost:3000" - curlCheck "http://localhost:3100" - curlCheck "http://localhost:3170/ping" + curlCheck "http://localhost:3000" || exit 1 + curlCheck "http://localhost:3100" || exit 1 + curlCheck "http://localhost:3170/ping" || exit 1 fi