#!/bin/bash set -euo pipefail # If FLAG is set, write it to /app/flag.txt if [ -n "${FLAG:-}" ]; then echo "$FLAG" > /app/flag.txt chmod 644 /app/flag.txt fi # Start Gunicorn in background (2 workers, threaded model) gunicorn -w 2 -k gthread --threads 8 -b 0.0.0.0:80 app:app --timeout 30 --access-logfile - --error-logfile - & GUNICORN_PID=$! sleep 1 echo "[container] gunicorn started (pid $GUNICORN_PID)" # admin bot loop (same behavior as before) while true; do if [ "${ADMIN_BOT_ENABLED:-1}" = "1" ]; then if [ -f data/admin_token.txt ]; then TOKEN=$(cat data/admin_token.txt) echo "[container] running puppeteer admin bot" node bot/admin.js --base "${BASE_URL:-http://127.0.0.1:80}" --token "$TOKEN" --wait 3000 || true else echo "[container] admin token not found at data/admin_token.txt" fi else echo "[container] ADMIN_BOT_ENABLED != 1; sleeping" fi sleep ${ADMIN_BOT_INTERVAL:-15} done