Skip to content

Instantly share code, notes, and snippets.

@afonasev
Created February 5, 2019 07:38
Show Gist options
  • Save afonasev/ceb1812e7ed2f1972608aa854f0d7f9a to your computer and use it in GitHub Desktop.
Save afonasev/ceb1812e7ed2f1972608aa854f0d7f9a to your computer and use it in GitHub Desktop.
docker/entrypoint.sh
#!/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