diff --git a/Dockerfile b/Dockerfile index c6888cc..49491ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -105,12 +105,17 @@ ENV DEBIAN_FRONTEND=noninteractive \ # Asana importer app secret TAIGA_IMPORTER_ASANA_APP_SECRET="" \ DEBUG=false \ + # Default container user id TAIGA_UID=1000 \ + # Default container group id TAIGA_GID=1000 \ # List of plugins to enable eg. "slack, other, other" or just "slack" - TAIGA_PLUGINS="" + TAIGA_PLUGINS="" \ + # Interval (in seconds) for a background task that sends mails + MAIL_NOTIFICATIONS_SEND_EVERY=120 -COPY bin/plugins/plugin-manager.py /opt/riotkit/bin/plugin-manager.py +COPY bin/plugins/plugin-manager.py /opt/riotkit/bin/ +COPY bin/cron/send-mail-notifications.sh /opt/riotkit/bin/ COPY plugins /usr/src/taiga-plugins # install dependencies @@ -176,7 +181,7 @@ RUN cp /opt/taiga-conf/taiga/local.py /usr/src/taiga-back/settings/local.py \ && mkdir -p /var/log/nginx /var/lib/nginx \ && touch /var/run/nginx.pid -EXPOSE 80 443 +EXPOSE 80 9001 VOLUME /usr/src/taiga-back/media WORKDIR /usr/src/taiga-back diff --git a/README.md.j2 b/README.md.j2 index f910609..8a1b165 100644 --- a/README.md.j2 +++ b/README.md.j2 @@ -114,7 +114,20 @@ If you have trouble logging in or editing user settings it may be related to a f 2. Using existing database -See: https://github.com/riotkit-org/docker-taiga/issues/24 +Set `TAIGA_DB_HOST` to point to your PostgreSQL hostname. +See also: https://github.com/riotkit-org/docker-taiga/issues/24 + +3. Debugging, getting logs + +In container there is a supervisor configured. Use `supervisorctl` to access services. + +Examples: +```bash +supervisorctl status send_app_notifications +supervisorctl tail -f send_app_notifications stderr +supervisorctl tail -f backend stderr +supervisorctl tail -f nginx stderr +``` Developing the container ------------------------ diff --git a/bin/cron/send-mail-notifications.sh b/bin/cron/send-mail-notifications.sh new file mode 100755 index 0000000..67df688 --- /dev/null +++ b/bin/cron/send-mail-notifications.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# +# Simple background task that sends queued e-mails +# - Does not interrupt on failure +# - Controlled by supervisord, logs are grabbed by supervisor +# - Shows logs on stdout and stderr +# - Does not introduce additional dependencies on cron, exim and 60mb+ of others +# + +cd /usr/src/taiga-back + +MAIL_NOTIFICATIONS_SEND_EVERY=${MAIL_NOTIFICATIONS_SEND_EVERY:-120} + +while true; do + sleep ${MAIL_NOTIFICATIONS_SEND_EVERY} + echo " >> Sending all queued mails" + python manage.py send_notifications; exit_code=$? + echo " >> Done, exit code is ${exit_code}" +done diff --git a/supervisor.conf b/supervisor.conf index 6103f59..0e414d2 100644 --- a/supervisor.conf +++ b/supervisor.conf @@ -1,3 +1,12 @@ +[inet_http_server] +port=0.0.0.0:9001 + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=http://127.0.0.1:9001 + [supervisord] logfile=/var/log/supervisord.log ; supervisord log file logfile_maxbytes=5MB ; maximum size of logfile before rotation @@ -6,6 +15,10 @@ loglevel=debug ; info, debug, warn, trace nodaemon=true ; run supervisord as a daemon user=root ; default user childlogdir=/var/log ; where child log files will live +serverurl=unix:///run/supervisord.sock + +[unix_http_server] +file=/run/supervisord.sock [program:backend] command=gunicorn --workers 4 --timeout 60 -b 127.0.0.1:8000 taiga.wsgi @@ -16,3 +29,11 @@ stderr_events_enabled=true command=nginx -c /etc/nginx/nginx.conf stdout_events_enabled=true stderr_events_enabled=true + +[program:send_app_notifications] +user=taiga +autostart=true +autorestart=true +command=/bin/bash -c "/opt/riotkit/bin/send-mail-notifications.sh" +stdout_events_enabled=true +stderr_events_enabled=true