Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save lcamilo15/2cf68ce349ce24f9951aee9b69086af8 to your computer and use it in GitHub Desktop.

Select an option

Save lcamilo15/2cf68ce349ce24f9951aee9b69086af8 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