Skip to content

Instantly share code, notes, and snippets.

@deviantony
Created September 13, 2015 15:20
Show Gist options
  • Save deviantony/ddb93425dc6f011c4d8b to your computer and use it in GitHub Desktop.
Save deviantony/ddb93425dc6f011c4d8b to your computer and use it in GitHub Desktop.
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