Skip to content

Instantly share code, notes, and snippets.

@lvthillo
Created March 20, 2018 18:57
Show Gist options
  • Save lvthillo/7af222367a41e30c33c95455b7aa6191 to your computer and use it in GitHub Desktop.
Save lvthillo/7af222367a41e30c33c95455b7aa6191 to your computer and use it in GitHub Desktop.
wait-for-it.sh to Check if MySQL service is running using environment variables
#!/bin/bash
set -e
host="$1"
shift
cmd="$@"
until mysql -hmysql -p"3306" -u"${database__connection__user}" -p"${database__connection__password}"
-D"${database__connection__database}" ; do
>&2 echo "MySQL is unavailable - sleeping"
sleep 1
done
>&2 echo "MySQL is up - executing command"
exec "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment