Created
February 5, 2019 07:38
-
-
Save afonasev/ceb1812e7ed2f1972608aa854f0d7f9a to your computer and use it in GitHub Desktop.
docker/entrypoint.sh
This file contains hidden or 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 | |
function db_ready(){ | |
python << END | |
import sys | |
import sqlalchemy | |
try: | |
engine_pro = sqlalchemy.create_engine("${DATABASE}").connect() | |
except (sqlalchemy.exc.SQLAlchemyError, sqlalchemy.exc.DBAPIError) as e: | |
print('Error:', e) | |
sys.exit(-1) | |
sys.exit(0) | |
END | |
} | |
until db_ready; do | |
>&2 echo 'Waiting for database to become available...' | |
sleep 1 | |
done | |
>&2 echo 'Database is available' | |
exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment