Created
September 10, 2018 05:51
-
-
Save heysamtexas/a79c8423a38cb52481acefc5126d3803 to your computer and use it in GitHub Desktop.
DOCKER - Small inline bash function with inline python script to wait for database to be ready
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function postgres_ready(){ | |
python << END | |
import sys | |
import psycopg2 | |
try: | |
conn = psycopg2.connect(dbname="$DB_NAME", user="$DB_USER", password="$DB_PASS", host="$DB_HOST") | |
except psycopg2.OperationalError: | |
sys.exit(-1) | |
sys.exit(0) | |
END | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment