Skip to content

Commit 1779fbd

Browse files
blizzard4591Jana Berger
authored and
Jana Berger
committed
Okay, same for Postorius.
1 parent 03483dc commit 1779fbd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

postorius/docker-entrypoint.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@ function wait_for_postgres () {
1616

1717
function wait_for_mysql () {
1818
# Check if MySQL is up and accepting connections.
19-
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'));")
20-
until mysqladmin ping --host ${ENDPOINT[0]} --port ${ENDPOINT[1]} --silent; do
19+
# The LAST_ELEMENT is necessary to circumvent the socket picking up the newline
20+
readarray -d' ' -t ENDPOINT <<< $(python3 -c "from urllib.parse import urlparse; from urllib.parse import parse_qs; o = urlparse('$DATABASE_URL'); q = parse_qs(o.query); print('%s %s %s %s' % (o.hostname, o.port if o.port else '3306', q['unix_socket'][0] if 'unix_socket' in q else 'NONE_SPECIFIED', 'LAST_ELEMENT'));")
21+
COMMAND=""
22+
COMMAND_ARG=""
23+
if [[ "${ENDPOINT[2]}" == "NONE_SPECIFIED" ]] ;
24+
then
25+
COMMAND="--host"
26+
COMMAND_ARG="${ENDPOINT[0]}"
27+
else
28+
COMMAND="-S"
29+
COMMAND_ARG="${ENDPOINT[2]}"
30+
fi
31+
until mysqladmin ping ${COMMAND} ${COMMAND_ARG} --port ${ENDPOINT[1]} --silent; do
2132
>&2 echo "MySQL is unavailable - sleeping"
2233
sleep 1
2334
done

0 commit comments

Comments
 (0)