summaryrefslogtreecommitdiff
path: root/docker-run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'docker-run.sh')
-rwxr-xr-xdocker-run.sh20
1 files changed, 19 insertions, 1 deletions
diff --git a/docker-run.sh b/docker-run.sh
index f147b77..29ffa7b 100755
--- a/docker-run.sh
+++ b/docker-run.sh
@@ -1,6 +1,22 @@
-#!/bin/sh
+#!/bin/bash
set -eu
+WAIT_DB_HOST=${TRAVELYNX_DB_HOST}
+WAIT_DB_PORT=5432
+
+wait_for_db() {
+ set +e
+ for i in $(seq 1 ${WAIT_DB_TIMEOUT:-5})
+ do
+ (echo >/dev/tcp/${WAIT_DB_HOST}/${WAIT_DB_PORT}) &>/dev/null
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ sleep 1
+ done
+ set -e
+}
+
if [ ! -f travelynx.conf ]
then
echo "The configuration file is missing"
@@ -17,6 +33,8 @@ then
export EMAIL_SENDER_TRANSPORT_PORT=${TRAVELYNX_MAIL_PORT:-25}
fi
+wait_for_db
+
perl index.pl database migrate
exec /usr/local/bin/hypnotoad -f index.pl