- README, 예제 설명, 코드 주석, CSS 머리말, 시험 임시 폴더 접두어의 예전 이름 정리 - 브라우저 저장 키·세션 DB 이름은 저장된 설정 보존을 위해 유지
113 lines
3.0 KiB
Batchfile
113 lines
3.0 KiB
Batchfile
@echo off
|
|
title SPipe Launcher
|
|
|
|
echo ========================================================
|
|
echo SPipe Local WebApp Launcher
|
|
echo ========================================================
|
|
echo.
|
|
|
|
:: 1. Working directory and paths
|
|
set "ROOT_DIR=%~dp0"
|
|
set "PYTHON_EXE=%ROOT_DIR%.venv\Scripts\python.exe"
|
|
|
|
cd /d "%ROOT_DIR%"
|
|
echo [1/5] Working directory: %CD%
|
|
|
|
:: 2. Check Node / npm
|
|
where npm >nul 2>&1
|
|
if errorlevel 1 goto ERR_NO_NPM
|
|
echo [2/5] Node and npm verified.
|
|
|
|
:: 3. Check Python executable
|
|
if not exist "%PYTHON_EXE%" goto ERR_NO_VENV
|
|
echo [3/5] Python virtual environment verified.
|
|
|
|
:: 4. Check if ports are already busy
|
|
set PORT8000_BUSY=0
|
|
set PORT5173_BUSY=0
|
|
|
|
netstat -ano | findstr /R /C:":8000 .*LISTENING" >nul 2>&1
|
|
if not errorlevel 1 set PORT8000_BUSY=1
|
|
|
|
netstat -ano | findstr /R /C:":5173 .*LISTENING" >nul 2>&1
|
|
if not errorlevel 1 set PORT5173_BUSY=1
|
|
|
|
if "%PORT8000_BUSY%"=="1" if "%PORT5173_BUSY%"=="1" goto ALREADY_RUNNING
|
|
|
|
:: 5. Launch Backend and Frontend
|
|
echo [4/5] Launching SPipe servers...
|
|
|
|
if "%PORT8000_BUSY%"=="0" (
|
|
echo - Starting SPipe API Backend on Port 8000
|
|
start "SPipe API" cmd /k "cd /d "%ROOT_DIR%" && "%PYTHON_EXE%" -m uvicorn backend.main:app --host 127.0.0.1 --port 8000"
|
|
) else (
|
|
echo - SPipe API Backend is already active on Port 8000
|
|
)
|
|
|
|
if "%PORT5173_BUSY%"=="0" (
|
|
echo - Starting SPipe Web Frontend on Port 5173
|
|
start "SPipe Web" cmd /k "cd /d "%ROOT_DIR%" && npm run dev"
|
|
) else (
|
|
echo - SPipe Web Frontend is already active on Port 5173
|
|
)
|
|
|
|
:: 6. Healthcheck wait loop: Wait until both ports are listening
|
|
echo [5/5] Waiting for both servers to be ready...
|
|
set WAIT_COUNT=0
|
|
|
|
:WAIT_LOOP
|
|
ping 127.0.0.1 -n 2 >nul
|
|
netstat -ano | findstr /R /C:":8000 .*LISTENING" >nul 2>&1
|
|
if errorlevel 1 goto RETRY_WAIT
|
|
|
|
netstat -ano | findstr /R /C:":5173 .*LISTENING" >nul 2>&1
|
|
if errorlevel 1 goto RETRY_WAIT
|
|
|
|
goto READY_LAUNCH
|
|
|
|
:RETRY_WAIT
|
|
set /a WAIT_COUNT+=1
|
|
if %WAIT_COUNT% lss 15 (
|
|
echo - Initializing servers... [%WAIT_COUNT%/15]
|
|
goto WAIT_LOOP
|
|
)
|
|
|
|
:READY_LAUNCH
|
|
echo.
|
|
echo [DONE] Both servers are online and ready!
|
|
echo [DONE] Opening browser: http://127.0.0.1:5173
|
|
start http://127.0.0.1:5173
|
|
|
|
echo.
|
|
echo ========================================================
|
|
echo * Backend API : http://127.0.0.1:8000
|
|
echo * Web Frontend : http://127.0.0.1:5173
|
|
echo.
|
|
echo * To stop servers, double-click: stop-spipe.bat
|
|
echo ========================================================
|
|
echo.
|
|
pause
|
|
exit /b 0
|
|
|
|
:ALREADY_RUNNING
|
|
echo [NOTICE] Both Backend and Frontend are already running.
|
|
echo [NOTICE] Opening browser: http://127.0.0.1:5173
|
|
start http://127.0.0.1:5173
|
|
echo.
|
|
pause
|
|
exit /b 0
|
|
|
|
:ERR_NO_NPM
|
|
echo [ERROR] npm was not found in PATH.
|
|
echo Please install Node.js LTS from https://nodejs.org
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
|
|
:ERR_NO_VENV
|
|
echo [ERROR] %PYTHON_EXE% was not found.
|
|
echo Please create .venv and install requirements first.
|
|
echo.
|
|
pause
|
|
exit /b 1
|