Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SH entrypoint for docker-compose to manage dependency startup.
#!/usr/bin/env sh
# Wait for a HTTP service to be OK (return code 200) before trying to start another service.
echo "Stalling for SERVICE"
while true; do
status=$(curl --write-out %{http_code} --silent --output /dev/null http://service.domain/endpoint)
echo "Status: ${status}"
if [ "${status}" == "200" ]; then
break
else
echo "SERVICE is not yet available. Waiting..."
sleep 10
fi
done
echo "Starting OTHER_SERVICE"
// Start your other service here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment