Files
eene_dashboard/start-server.bat
EENE Dashboard fb2956b0ac feat: team org panel, admin CRUD, local deploy tools, bidirectional data sync
Add TeamMember model and APIs, team status UI, /admin page, local server bats,
and scripts to sync data between local PostgreSQL and Render.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 01:41:00 +09:00

141 lines
3.4 KiB
Batchfile

@echo off
REM Keep window open via cmd /k
if /i not "%~1"=="_run" (
cd /d "%~dp0"
cmd /k "%~f0" _run
exit /b 0
)
setlocal EnableDelayedExpansion
chcp 65001 >nul
cd /d "%~dp0"
title EENE Dashboard - Running
echo ================================
echo EENE Dashboard - Server Start
echo ================================
echo.
REM --- [1/5] Stop old API/WEB ---
echo [1/5] Stopping old API/WEB servers...
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\kill-ports.ps1" 2>nul
ping 127.0.0.1 -n 3 >nul
echo Done.
echo.
REM --- [2/5] Database ---
echo [2/5] Starting Database...
set "DB_MODE=unknown"
where docker >nul 2>&1
if %errorlevel%==0 if exist "%~dp0docker-compose.yml" (
echo Trying Docker...
docker compose up -d 2>nul
if !errorlevel!==0 set "DB_MODE=docker"
)
if "!DB_MODE!"=="unknown" (
sc query postgresql-x64-16 2>nul | findstr /i "RUNNING" >nul 2>&1
if !errorlevel!==0 (
set "DB_MODE=windows"
echo Windows PostgreSQL running.
) else (
sc query postgresql-x64-16 >nul 2>&1
if !errorlevel!==0 (
echo Starting Windows PostgreSQL...
net start postgresql-x64-16 >nul 2>&1
if !errorlevel!==0 set "DB_MODE=windows"
)
)
)
if "!DB_MODE!"=="unknown" (
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\wait-db.ps1" >nul 2>&1
if !errorlevel!==0 (
set "DB_MODE=local"
echo PostgreSQL on port 5432 detected.
)
)
if "!DB_MODE!"=="unknown" (
echo.
echo [ERROR] No database found.
echo - Start postgresql-x64-16 service, OR
echo - Start Docker Desktop and retry
echo - Check backend\.env DATABASE_URL:
echo postgresql://postgres:eee_password@localhost:5432/eee_dashboard
echo.
goto :end_error
)
echo DB mode: !DB_MODE!
echo.
REM --- [3/5] Wait DB port ---
echo [3/5] Waiting for port 5432...
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\wait-db.ps1"
if errorlevel 1 (
echo [ERROR] Port 5432 not ready.
goto :end_error
)
echo Done.
echo.
REM --- [4/5] Schema sync ---
echo [4/5] DB schema sync...
cd /d "%~dp0backend"
if not exist "node_modules\" (
echo npm install - backend...
call npm install
if errorlevel 1 goto :end_error
)
call npm run db:sync
if errorlevel 1 (
echo.
echo [ERROR] DB sync failed. Check backend\.env DATABASE_URL
echo postgresql://postgres:eee_password@localhost:5432/eee_dashboard
goto :end_error
)
call npx prisma generate
if errorlevel 1 goto :end_error
cd /d "%~dp0"
echo Done.
echo.
REM --- [5/5] Start servers ---
echo [5/5] Starting Backend + Frontend...
if not exist "%~dp0frontend\node_modules\" (
echo npm install - frontend...
cd /d "%~dp0frontend"
call npm install
if errorlevel 1 goto :end_error
cd /d "%~dp0"
)
if not exist "%~dp0uploads\team\" mkdir "%~dp0uploads\team" 2>nul
set "LAN_IP=localhost"
for /f "delims=" %%I in ('powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\get-lan-ip.ps1" 2^>nul') do set "LAN_IP=%%I"
echo.
echo Dashboard : http://localhost:3000
echo Admin : http://localhost:3000/admin
echo LAN : http://!LAN_IP!:3000
echo Stop : stop-server.bat
echo ================================
echo.
npx --yes concurrently -k -n "API,WEB" -c "cyan,green" "cd /d %~dp0backend && npm run dev" "cd /d %~dp0frontend && npm run dev"
echo.
echo Server stopped.
goto :end_ok
:end_error
echo.
echo Press any key to close...
pause >nul
exit /b 1
:end_ok
pause