entry point for Django application
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
#!/bin/bash | |
set -e | |
cmd="$@" | |
function postgres_ready(){ | |
python << END | |
import sys | |
import psycopg2 | |
try: | |
# conn = psycopg2.connect(dbname="$POSTGRES_USER", user="$POSTGRES_USER", password="$POSTGRES_PASSWORD", host="postgres") | |
conn = psycopg2.connect(dbname="postgres", user="postgres", password="", host="db") | |
except psycopg2.OperationalError: | |
sys.exit(-1) | |
sys.exit(0) | |
END | |
} | |
until postgres_ready; do | |
>&2 echo "Postgres is unavailable - sleeping" | |
sleep 1 | |
done | |
>&2 echo "Postgres is up - continuing..." | |
# export REDIS_URL=redis://redis:6379/0 | |
export DATABASE_URL=postgres://postgres:@db:5432/postgres | |
exec $cmd | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment