#!/bin/bash # ── Recap Studio startup script (Webhook mode — HuggingFace Spaces) ── echo "===== Application Startup at $(date '+%Y-%m-%d %H:%M:%S') =====" echo "🚀 Starting Recap Studio..." PORT=${PORT:-7860} WORKERS=1 THREADS=8 # Kill any stale bot processes (leftover from polling era) echo "🔪 Killing stale bot processes..." pkill -f "python.*bot.py" 2>/dev/null || true pkill -f "python.*run_bot.py" 2>/dev/null || true sleep 2 # NOTE: Webhook registration is handled inside app.py (_start_ptb thread). # No curl calls to api.telegram.org needed here — HuggingFace blocks # outbound connections to Telegram at startup anyway. echo "🌐 Starting Gunicorn on port $PORT..." exec gunicorn app:app \ --bind "0.0.0.0:$PORT" \ --workers $WORKERS \ --threads $THREADS \ --worker-class gthread \ --timeout 120 \ --keep-alive 5 \ --log-level info \ --access-logfile - \ --error-logfile -