Skip to content

Commit

Permalink
Fix behavior during initialization timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
fpytloun committed Apr 28, 2017
1 parent 6b1dc54 commit c3c29b7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
5 changes: 3 additions & 2 deletions 5.5/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then

mysql=( mysql --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" )

for i in {30..0}; do
for i in {${MYSQL_START_TIMEOUT:-30}..0}; do
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
break
fi
echo 'MySQL init process in progress...'
sleep 1
done
if [ "$i" = 0 ]; then
echo >&2 'MySQL init process failed.'
echo >&2 'MySQL init process failed. Cleaning up..'
rm -rf $DATADIR/mysql
exit 1
fi

Expand Down
7 changes: 4 additions & 3 deletions 5.6/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then

mysql=( mysql --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" )

for i in {30..0}; do
for i in $(seq ${MYSQL_START_TIMEOUT:-30} -1 1); do
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
break
fi
echo 'MySQL init process in progress...'
echo "MySQL init process in progress..."
sleep 1
done
if [ "$i" = 0 ]; then
echo >&2 'MySQL init process failed.'
echo >&2 'MySQL init process failed. Cleaning up..'
rm -rf $DATADIR/mysql
exit 1
fi

Expand Down
5 changes: 3 additions & 2 deletions 5.7/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then

mysql=( mysql --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" )

for i in {30..0}; do
for i in {${MYSQL_START_TIMEOUT:-30}..0}; do
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
break
fi
echo 'MySQL init process in progress...'
sleep 1
done
if [ "$i" = 0 ]; then
echo >&2 'MySQL init process failed.'
echo >&2 'MySQL init process failed. Cleaning up..'
rm -rf $DATADIR/mysql
exit 1
fi

Expand Down
5 changes: 3 additions & 2 deletions 8.0/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then

mysql=( mysql --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" )

for i in {30..0}; do
for i in {${MYSQL_START_TIMEOUT:-30}..0}; do
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
break
fi
echo 'MySQL init process in progress...'
sleep 1
done
if [ "$i" = 0 ]; then
echo >&2 'MySQL init process failed.'
echo >&2 'MySQL init process failed. Cleaning up..'
rm -rf $DATADIR/mysql
exit 1
fi

Expand Down

0 comments on commit c3c29b7

Please sign in to comment.