first commit
This commit is contained in:
28
health_check.sh
Executable file
28
health_check.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define the URL of your health endpoint
|
||||
HEALTH_ENDPOINT="http://localhost:3000/health"
|
||||
# Make a GET request to the health endpoint and capture the response
|
||||
RESPONSE=$(wget -qO- --timeout=2 "$HEALTH_ENDPOINT" )
|
||||
|
||||
# Display the response from the health endpoint
|
||||
echo "Response from health endpoint: $RESPONSE"
|
||||
|
||||
# Extract the value of the "status" field using jq
|
||||
status=$(echo "$RESPONSE" | jq -r '.status')
|
||||
|
||||
# Check if the status is "ok"
|
||||
if [[ "$status" == "ok" ]]; then
|
||||
echo "Health check successful"
|
||||
exit 0 # Exit with success status
|
||||
else
|
||||
echo "Health check failed"
|
||||
exit 1 # Exit with failure status
|
||||
fi
|
||||
# if [[ "$RESPONSE" =~ '"status": "ok"' ]]; then
|
||||
# echo "Health check successful"
|
||||
# exit 0 # Exit with success status
|
||||
# else
|
||||
# echo "Health check failed: $RESPONSE"
|
||||
# exit 1 # Exit with failure status
|
||||
# fi
|
||||
Reference in New Issue
Block a user