From a9e85760c7b18590f5044061cd7da90061c96533 Mon Sep 17 00:00:00 2001 From: Lars Tangvald Date: Thu, 6 Sep 2018 11:55:16 +0200 Subject: [PATCH] Template: Use --daemonize for temporary server startup. When using --daemonize, the server process will fork and exit when the server is ready for use, removing the need for a wait loop. Note: This is only supported for 5.7+ --- .template.Debian/docker-entrypoint.sh | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/.template.Debian/docker-entrypoint.sh b/.template.Debian/docker-entrypoint.sh index e0e0112cb..1fe2d4ef3 100755 --- a/.template.Debian/docker-entrypoint.sh +++ b/.template.Debian/docker-entrypoint.sh @@ -92,21 +92,11 @@ _get_config() { _start_server() { local socket=$1; shift - "$@" --skip-networking --socket="${socket}" & - local pid="$!" - - mysql=( mysql --protocol=socket -uroot -hlocalhost --socket="${socket}" ) - - for i in {30..0}; do - if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then - break - fi - sleep 1 - done - if [ "$i" = 0 ]; then - _error "Unable to start server." + result=0 + "$@" --daemonize --skip-networking --socket="${socket}" || result=$? + if [ ! "$result" = "0" ];then + _error "Unable to start server. Status code $result." fi - return $pid } _stop_server() { @@ -154,8 +144,8 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then SOCKET="$(_get_config 'socket' "$@")" _note "Starting server" - _start_server "${SOCKET}" "$@" || pid=$? - _note "Server started with pid $pid" + _start_server "${SOCKET}" "$@" + _note "Server started with." mysql=( mysql --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" )