#!/bin/bash
# Stop development mode processes

echo "Stopping Church Music System development processes..."

# Stop backend
if [ -f /tmp/church-backend.pid ]; then
    PID=$(cat /tmp/church-backend.pid)
    if ps -p $PID > /dev/null 2>&1; then
        kill $PID
        echo "✓ Backend stopped (PID: $PID)"
    fi
    rm /tmp/church-backend.pid
fi

# Stop frontend
if [ -f /tmp/church-frontend.pid ]; then
    PID=$(cat /tmp/church-frontend.pid)
    if ps -p $PID > /dev/null 2>&1; then
        kill $PID
        echo "✓ Frontend stopped (PID: $PID)"
    fi
    rm /tmp/church-frontend.pid
fi

# Also kill any stray processes
pkill -f "python app.py" 2>/dev/null || true
pkill -f "react-scripts start" 2>/dev/null || true
pkill -9 -f "webpack-dev-server" 2>/dev/null || true

echo "✅ Development mode stopped"
