#!/bin/bash set -e # Logging function log() { echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1" } log "🚀 Starting MicroFunnel Backend..." log "📂 Working Directory: $(pwd)" log "👤 User: $(whoami)" # 1. Run Migrations log "🛠️ Running Database Migrations..." if alembic upgrade head; then log "✅ Migrations applied successfully." else log "❌ Migration failed!" exit 1 fi # 2. Verify Port PORT="${PORT:-8000}" log "🔌 Starting Server on 0.0.0.0:$PORT" # 3. Start Uvicorn # Use exec to replace shell process with uvicorn for signal handling exec python -m uvicorn app.main:app --host 0.0.0.0 --port "$PORT" --log-level info