Skip to content

Commit

Permalink
chore: improve health check script (hoppscotch#4596)
Browse files Browse the repository at this point in the history
Consider capturing and returning the exit status from `curlCheck()` rather than `exit 1` inside the function
  • Loading branch information
progprnv authored and jamesgeorge007 committed Feb 7, 2025
1 parent 0aa509e commit 56900d3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions healthcheck.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 56900d3

Please sign in to comment.