Skip to content

Instantly share code, notes, and snippets.

@ricardodantas
Last active October 27, 2021 12:36
Show Gist options
  • Save ricardodantas/0d448f3005bf4025550c50cf238dfa8b to your computer and use it in GitHub Desktop.
Save ricardodantas/0d448f3005bf4025550c50cf238dfa8b to your computer and use it in GitHub Desktop.
Bash Script utility to check if the services are up and running.
#!/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