summaryrefslogtreecommitdiff
path: root/docker-run.sh
diff options
context:
space:
mode:
authorMarkus Witt <feuerrot@feuerrot.org>2019-05-03 22:50:59 +0200
committerMarkus Witt <feuerrot@feuerrot.org>2019-05-03 22:50:59 +0200
commit2b5780499c3e00e1969c461b864994757a21a8d8 (patch)
tree695bfb16ec179debf7aebd74e9f82dd881cba7a1 /docker-run.sh
parent46e85324df762672718c0a6a5ca60fb247e89e5d (diff)
use cpanfile to install dependencies, run worker in another docker container
Diffstat (limited to 'docker-run.sh')
-rwxr-xr-xdocker-run.sh50
1 files changed, 34 insertions, 16 deletions
diff --git a/docker-run.sh b/docker-run.sh
index 29ffa7b..696aa35 100755
--- a/docker-run.sh
+++ b/docker-run.sh
@@ -4,6 +4,14 @@ set -eu
WAIT_DB_HOST=${TRAVELYNX_DB_HOST}
WAIT_DB_PORT=5432
+check_config() {
+ if [ ! -f travelynx.conf ]
+ then
+ echo "The configuration file is missing"
+ exit 1
+ fi
+}
+
wait_for_db() {
set +e
for i in $(seq 1 ${WAIT_DB_TIMEOUT:-5})
@@ -11,30 +19,40 @@ wait_for_db() {
(echo >/dev/tcp/${WAIT_DB_HOST}/${WAIT_DB_PORT}) &>/dev/null
if [ $? -eq 0 ]; then
break
+ else
+ echo "Can't reach DB @ ${WAIT_DB_HOST}:${WAIT_DB_PORT}"
fi
sleep 1
done
set -e
}
-if [ ! -f travelynx.conf ]
-then
- echo "The configuration file is missing"
- exit 1
-fi
+run_app() {
+ if [ \
+ "${TRAVELYNX_MAIL_DISABLE:-0}" -eq 0 \
+ -a "${TRAVELYNX_MAIL_HOST:-unset}" != "unset" \
+ ]
+ then
+ export EMAIL_SENDER_TRANSPORT=SMTP
+ export EMAIL_SENDER_TRANSPORT_HOST=${TRAVELYNX_MAIL_HOST}
+ export EMAIL_SENDER_TRANSPORT_PORT=${TRAVELYNX_MAIL_PORT:-25}
+ fi
-if [ \
- "${TRAVELYNX_MAIL_DISABLE:-0}" -eq 0 \
- -a "${TRAVELYNX_MAIL_HOST:-unset}" != "unset" \
-]
-then
- export EMAIL_SENDER_TRANSPORT=SMTP
- export EMAIL_SENDER_TRANSPORT_HOST=${TRAVELYNX_MAIL_HOST}
- export EMAIL_SENDER_TRANSPORT_PORT=${TRAVELYNX_MAIL_PORT:-25}
-fi
+ perl index.pl database migrate
+ exec /usr/local/bin/hypnotoad -f index.pl
+}
+
+run_cron() {
+ exec perl index.pl worker
+}
+
+check_config
wait_for_db
-perl index.pl database migrate
+if [ "${CRON:-0}" -ne "0" ]
+then
+ run_cron
+fi
-exec /usr/local/bin/hypnotoad -f index.pl
+run_app \ No newline at end of file