Files
storyteller/start.bat
Aodhan Collins eccd456c59 Initial commit
2025-10-11 21:21:36 +01:00

88 lines
2.1 KiB
Batchfile

@echo off
REM Storyteller RPG Startup Script for Windows
REM This script starts both the backend and frontend servers
echo.
echo 🎭 Starting Storyteller RPG...
echo.
REM Kill any existing instances
echo Checking for existing instances...
REM Kill processes on port 8000 (backend)
for /f "tokens=5" %%a in ('netstat -aon ^| find ":8000" ^| find "LISTENING"') do (
echo Killing existing backend on port 8000 (PID: %%a)
taskkill /F /PID %%a >nul 2>&1
)
REM Kill processes on port 3000 (frontend)
for /f "tokens=5" %%a in ('netstat -aon ^| find ":3000" ^| find "LISTENING"') do (
echo Killing existing frontend on port 3000 (PID: %%a)
taskkill /F /PID %%a >nul 2>&1
)
REM Wait for ports to be released
timeout /t 2 /nobreak >nul
echo Ready to start fresh instances
echo.
REM Check if virtual environment exists
if not exist ".venv" (
echo Creating virtual environment...
python -m venv .venv
)
REM Activate virtual environment
echo Activating virtual environment...
call .venv\Scripts\activate.bat
REM Install backend dependencies if needed
python -c "import fastapi" 2>nul
if errorlevel 1 (
echo Installing backend dependencies...
pip install -r requirements.txt
)
REM Check if frontend dependencies are installed
if not exist "frontend\node_modules" (
echo Installing frontend dependencies...
cd frontend
call npm install
cd ..
)
echo.
echo Starting Backend (http://localhost:8000)...
start "Storyteller Backend" cmd /k "python main.py"
REM Wait a moment for backend to start
timeout /t 3 /nobreak >nul
echo Starting Frontend (http://localhost:3000)...
cd frontend
start "Storyteller Frontend" cmd /k "npm start"
cd ..
echo.
echo ✅ Servers are starting!
echo Backend: http://localhost:8000
echo Frontend: http://localhost:3000
echo.
REM Wait for frontend to be ready, then open browser
echo Waiting for frontend to start...
:wait_loop
timeout /t 1 /nobreak >nul
curl -s http://localhost:3000 >nul 2>&1
if errorlevel 1 goto wait_loop
echo Frontend ready! Opening browser...
start http://localhost:3000
echo.
echo Both servers are running in separate windows.
echo Close those windows to stop the servers.
echo.
pause