Last active
October 27, 2021 12:36
-
-
Save ricardodantas/0d448f3005bf4025550c50cf238dfa8b to your computer and use it in GitHub Desktop.
Bash Script utility to check if the services are up and running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SERVICES_LIST=(http://localhost:3001/healthcheck http://localhost:3000/healthcheck) | |
isServiceReady(){ | |
ping=$(curl -s -f -LI $1) | |
if [ -z "$ping" ]; then | |
false; | |
else | |
true; | |
fi | |
return $?; | |
} | |
for serviceUrl in "${SERVICES_LIST[@]}"; do | |
echo "Waiting for service $serviceUrl..."; | |
while ! isServiceReady $serviceUrl ; do | |
sleep 1 | |
done | |
echo "$serviceUrl is up"; | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment