Skip to content

Commit 697ce2a

Browse files
committed
Cleanup db check so it doesn't spam the console
1 parent fa84257 commit 697ce2a

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

root/etc/cont-init.d/50-config

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ do
3535
fi
3636
done
3737

38-
# Echo init finish for test runs
39-
if [ -n "${TEST_RUN}" ]; then
40-
echo '[services.d] done.'
41-
fi
42-
4338
# Create API key if needed
4439
if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ];
4540
then
@@ -95,24 +90,22 @@ if ! grep -qx '^post_max_size.*$' /config/php/php-local.ini; then
9590
echo 'post_max_size = 100M' >> /config/php/php-local.ini
9691
fi
9792

98-
# check for the mysql endpoint for 30 seconds
93+
# check for the mysql endpoint
94+
echo "Waiting for DB to be available"
9995
END=$((SECONDS+30))
100-
while [ ${SECONDS} -lt ${END} ] && [ -n "${DB_HOST+x}" ]; do
101-
if /usr/bin/nc -z ${DB_HOST} 3306; then
102-
if [ ! -z "$(/usr/bin/nc -w1 ${DB_HOST} 3306)" ]; then
103-
if [ ! -z "${RUN}" ]; then
104-
break
105-
fi
106-
RUN="RAN"
107-
# we sleep here again due to first run init on DB containers
108-
if [ ! -f /dbwait.lock ]; then
109-
sleep 5
110-
fi
111-
else
112-
sleep 1
96+
while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do
97+
if [[ $(/usr/bin/nc -w1 "${DB_HOST}" 3306 | tr -d '\0') ]]; then
98+
if [[ -n "${RUN}" ]]; then
99+
break
100+
fi
101+
RUN="RAN"
102+
# we sleep here again due to first run init on DB containers
103+
if [[ ! -f /dbwait.lock ]]; then
104+
sleep 5
113105
fi
106+
else
107+
sleep 1
114108
fi
115-
sleep 1
116109
done
117110

118111
# update database - will set up database if fresh, or, migrate existing

0 commit comments

Comments
 (0)