Skip to content

Instantly share code, notes, and snippets.

@pamtrak06
Created December 3, 2017 21:46
Show Gist options
  • Save pamtrak06/2942341a866ef0e519fbedc4c43b2710 to your computer and use it in GitHub Desktop.
Save pamtrak06/2942341a866ef0e519fbedc4c43b2710 to your computer and use it in GitHub Desktop.
#!/bin/bash
# wait-for-postgres.sh
# source : https://docs.docker.com/compose/startup-order/
set -e
host="$1"
shift
cmd="$@"
until psql -h "$host" -U "postgres" -c '\q'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
>&2 echo "Postgres is up - executing command"
exec $cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment