From b443ca12a70ded736cb33c19231db6413c4c3c0d Mon Sep 17 00:00:00 2001 From: Jack Henschel Date: Fri, 14 Sep 2018 13:41:47 +0200 Subject: [PATCH] Add socket check before waiting for database connection database connection checking with netcat is only possible when using a TCP/IP connection, just launch the application when the user chooses a unix socket --- apache/entrypoint.sh | 13 ++++++++----- fpm-alpine/entrypoint.sh | 15 +++++++++------ fpm/entrypoint.sh | 13 ++++++++----- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/apache/entrypoint.sh b/apache/entrypoint.sh index 7467dce..5f7b9a8 100755 --- a/apache/entrypoint.sh +++ b/apache/entrypoint.sh @@ -5,6 +5,7 @@ DB_TYPE=${DB_TYPE:-'mysql'} DB_HOST=${DB_HOST:-'mysql'} DB_PORT=${DB_PORT:-'3306'} +DB_SOCK=${DB_SOCK:-} DB_NAME=${DB_NAME:-'limesurvey'} DB_TABLE_PREFIX=${DB_TABLE_PREFIX:-'lime_'} DB_USERNAME=${DB_USERNAME:-'limesurvey'} @@ -20,11 +21,13 @@ URL_FORMAT=${URL_FORMAT:-'path'} # Check if database is available -until nc -z -v -w30 $DB_HOST $DB_PORT -do - echo "Info: Waiting for database connection..." - sleep 5 -done +if [ -z "$DB_SOCK" ]; then + until nc -z -v -w30 $DB_HOST $DB_PORT + do + echo "Info: Waiting for database connection..." + sleep 5 + done +fi # Check if already provisioned diff --git a/fpm-alpine/entrypoint.sh b/fpm-alpine/entrypoint.sh index 508e19a..5f7b9a8 100755 --- a/fpm-alpine/entrypoint.sh +++ b/fpm-alpine/entrypoint.sh @@ -1,10 +1,11 @@ -#!/bin/sh +#!/bin/bash # Entrypoint for Docker Container DB_TYPE=${DB_TYPE:-'mysql'} DB_HOST=${DB_HOST:-'mysql'} DB_PORT=${DB_PORT:-'3306'} +DB_SOCK=${DB_SOCK:-} DB_NAME=${DB_NAME:-'limesurvey'} DB_TABLE_PREFIX=${DB_TABLE_PREFIX:-'lime_'} DB_USERNAME=${DB_USERNAME:-'limesurvey'} @@ -20,11 +21,13 @@ URL_FORMAT=${URL_FORMAT:-'path'} # Check if database is available -until nc -z -v -w30 $DB_HOST $DB_PORT -do - echo "Info: Waiting for database connection..." - sleep 5 -done +if [ -z "$DB_SOCK" ]; then + until nc -z -v -w30 $DB_HOST $DB_PORT + do + echo "Info: Waiting for database connection..." + sleep 5 + done +fi # Check if already provisioned diff --git a/fpm/entrypoint.sh b/fpm/entrypoint.sh index 7467dce..5f7b9a8 100755 --- a/fpm/entrypoint.sh +++ b/fpm/entrypoint.sh @@ -5,6 +5,7 @@ DB_TYPE=${DB_TYPE:-'mysql'} DB_HOST=${DB_HOST:-'mysql'} DB_PORT=${DB_PORT:-'3306'} +DB_SOCK=${DB_SOCK:-} DB_NAME=${DB_NAME:-'limesurvey'} DB_TABLE_PREFIX=${DB_TABLE_PREFIX:-'lime_'} DB_USERNAME=${DB_USERNAME:-'limesurvey'} @@ -20,11 +21,13 @@ URL_FORMAT=${URL_FORMAT:-'path'} # Check if database is available -until nc -z -v -w30 $DB_HOST $DB_PORT -do - echo "Info: Waiting for database connection..." - sleep 5 -done +if [ -z "$DB_SOCK" ]; then + until nc -z -v -w30 $DB_HOST $DB_PORT + do + echo "Info: Waiting for database connection..." + sleep 5 + done +fi # Check if already provisioned