From e79800f49b76c67811e1e11643c618ca697c0507 Mon Sep 17 00:00:00 2001 From: Pierre-Gildas MILLON <715479+pgmillon@users.noreply.github.com> Date: Sun, 26 Dec 2021 19:44:29 +0100 Subject: [PATCH] Improve MySQL endpoint ping with custom ports --- core/docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/docker-entrypoint.sh b/core/docker-entrypoint.sh index 38338ad..9c6ab17 100755 --- a/core/docker-entrypoint.sh +++ b/core/docker-entrypoint.sh @@ -15,8 +15,8 @@ function wait_for_postgres () { function wait_for_mysql () { # Check if MySQL is up and accepting connections. - HOSTNAME=$(python3 -c "from urllib.parse import urlparse; o = urlparse('$DATABASE_URL'); print(o.hostname);") - until mysqladmin ping --host "$HOSTNAME" --silent; do + readarray -d' ' -t ENDPOINT <<< $(python3 -c "from urllib.parse import urlparse; o = urlparse('$DATABASE_URL'); print('%s %s' % (o.hostname, o.port if o.port else '3306'));") + until mysqladmin ping --host ${ENDPOINT[0]} --port ${ENDPOINT[1]} --silent; do >&2 echo "MySQL is unavailable - sleeping" sleep 1 done