@echo off
REM ========================================
REM Church SongLyric - Stop All Services
REM ========================================

title Stop All Services
color 0C

echo.
echo ========================================
echo STOPPING ALL CHURCH SONGLYRIC SERVICES
echo ========================================
echo.

echo [1/3] Stopping Frontend (Node.js)...
taskkill /FI "WindowTitle eq Church Frontend*" /T /F >nul 2>&1
tasklist /FI "IMAGENAME eq node.exe" 2>NUL | find /I /N "node.exe">NUL
if "%ERRORLEVEL%"=="0" (
    echo   Stopping all Node.js processes...
    taskkill /IM node.exe /F >nul 2>&1
    echo   Frontend stopped
) else (
    echo   Frontend not running
)

echo.
echo [2/3] Stopping Backend (Python)...
taskkill /FI "WindowTitle eq Church Backend*" /T /F >nul 2>&1
wmic process where "commandline like '%%app.py%%'" delete >nul 2>&1
echo   Backend stopped

echo.
echo [3/3] Stopping MongoDB (optional)...
echo   Note: MongoDB will keep running (recommended for quick restarts)
echo   To stop MongoDB manually, run: net stop MongoDB
echo.

echo ========================================
echo ALL SERVICES STOPPED!
echo ========================================
echo.
echo To restart, run: start-all-services.bat
echo.
pause
