#!/bin/bash
# Stop FastAPI backend server

echo "🛑 Stopping FastAPI server..."

# Find and kill uvicorn processes
pkill -f "uvicorn backend.app:app" 2>/dev/null

# Also kill any Python processes on port 8000
PID=$(lsof -ti :8000 2>/dev/null)
if [ ! -z "$PID" ]; then
    kill -9 $PID 2>/dev/null
    echo "✅ Killed process $PID on port 8000"
fi

sleep 1

# Verify port is free
if lsof -i :8000 >/dev/null 2>&1; then
    echo "⚠️  Port 8000 is still in use"
else
    echo "✅ Port 8000 is now free"
fi

