How to wait for a service to be up in Bash using cURL
This happened to me in a CI process before where I had to configure multiple process and wait for them to be up.
The following bash script will wait for the service running at service:8000 to be up before continuing:
found_message_in_a_bottle() {
curl --connect-timeout 2 -s service:8000 2>/dev/null| grep -q Welcome
}
wait_for_saltmaster() {
while ! found_message_in_a_bottle; do
echo wait for service...
sleep 1
done
}
Now run wait_for_saltmaster and the CI will hang until the service is up.