From 0aa55fd6b8414b9f35a2aaf5e4e2a10dd8b9e00e Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 24 Jun 2021 21:10:15 +1000 Subject: [PATCH] Changed init-php to wait on DB before starting server --- init-php.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/init-php.sh b/init-php.sh index 43b12e5..c0a48c4 100755 --- a/init-php.sh +++ b/init-php.sh @@ -1,6 +1,16 @@ -#!/bin/sh +#!/bin/bash # Run our web init startup /sbin/init php-fpm & +# Wait for DB to start +# If DB_HOST not set, source the env file +[ -z "${DB_HOST}" -a -r .env ] && . .env + +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}" + exec ./artisan server:start