Wait for the DB before running server in init-php

This commit is contained in:
Deon George 2021-07-18 23:48:43 +10:00
parent a37da4b099
commit 3756b0c565

View File

@ -4,6 +4,17 @@ set -e
BASE_DIR=storage/app
# If DB_HOST not set, source the env file
[ -z "${DB_HOST}" -a -r .env ] && . .env
if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then
while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do
echo "? Waiting for database at ${DB_HOST}:${DB_PORT}"
sleep 1;
done
echo "- DB is active on ${DB_HOST}:${DB_PORT}"
fi
# If FIDO_DIR not set, source the env file
[ -z "${FIDO_DIR}" -a -r .env ] && . .env