#!/bin/bash set -eu install -d -m 0755 -o slump -g slump /data/media /data/static gosu slump python manage.py migrate --noinput gosu slump python manage.py collectstatic --noinput web=(gosu slump gunicorn siteconfig.wsgi:application --bind 0.0.0.0:8000 --workers 2 --timeout 120 --access-logfile - --error-logfile -) if [[ ${SLX_NEWSLETTER_ENABLED:-0} != 1 ]]; then exec "${web[@]}" fi "${web[@]}" & web_pid=$! gosu slump python manage.py newsletter_worker & worker_pid=$! trap 'kill -TERM "$web_pid" "$worker_pid" 2>/dev/null || true; wait "$web_pid" "$worker_pid" || true; exit 0' TERM INT # Let Docker restart the service if one of the managed processes stops. wait -n "$web_pid" "$worker_pid" || true kill -TERM "$web_pid" "$worker_pid" 2>/dev/null || true wait "$web_pid" "$worker_pid" || true exit 1