Last active
November 19, 2016 14:07
-
-
Save thanhson1085/aded4c9c1ccc7938da0ddf256fc6472e to your computer and use it in GitHub Desktop.
Docker Entrypoint waits Mysql Started before running App
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 | |
host="$1" | |
password="$MYSQL_ROOT_PASSWORD" | |
until mysql -h "$host" -uroot -p$password; do | |
>&2 echo "MYSQL is unavailable - sleeping" | |
sleep 1 | |
done | |
>&2 echo "MYSQL is up - executing command" | |
# start service | |
>&2 echo "Start Service ...!" | |
cd /build && python3 run.py | |
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 | |
host="$1" | |
password="$MYSQL_PASS" | |
until mysql -h "$host" -uadmin -p$password; do | |
>&2 echo "MYSQL is unavailable - sleeping" | |
sleep 1 | |
done | |
while 1 | |
do | |
SQL_IS_RUNNING=$(mysql -h db_slave -upolsat -p$password -e "SHOW SLAVE STATUS\G" | grep "Slave_SQL_Running" | awk '{ print $2 }') | |
if [ "$SQL_IS_RUNNING" == "Yes" ] | |
then | |
break | |
fi | |
>&2 echo "MYSQL SLave is unavailable - sleeping" | |
sleep 1 | |
done | |
>&2 echo "MYSQL is up - executing command" | |
# run cron service | |
>&2 echo "Start Cron ...!" | |
cron | |
# run upgrade database | |
>&2 echo "Upgrade/Downgrade Db Schema...!" | |
cd /build && python3 manage.py db upgrade | |
# start service | |
>&2 echo "Start Service ...!" | |
cd /build && python3 run.py | |
#uwsgi --ini /build/wsgi.ini --uid root --gid www-data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment