74 lines
1.9 KiB
Batchfile
74 lines
1.9 KiB
Batchfile
|
|
@echo off
|
||
|
|
echo 🚀 Starting POZO Local Server...
|
||
|
|
echo.
|
||
|
|
|
||
|
|
REM Set development environment
|
||
|
|
set NODE_ENV=development
|
||
|
|
set ENV_MAIN_BASE_URL=http://localhost:3000
|
||
|
|
set ENV_BASE_URL=/
|
||
|
|
set ENV_API_URL=https://api.pozo.dev/pozo-common-api
|
||
|
|
set ENV_API_URL_TOKEN=https://api.pozo.dev/JwtToken
|
||
|
|
set ENV_API_URL_RETAIL=https://api.pozo.dev/pozo-retail-api
|
||
|
|
|
||
|
|
echo ✅ Environment variables set for development
|
||
|
|
echo.
|
||
|
|
|
||
|
|
REM Check if dist folder exists, if not build it
|
||
|
|
if not exist dist (
|
||
|
|
echo ❌ dist folder not found! Building project...
|
||
|
|
call npm run build
|
||
|
|
if errorlevel 1 (
|
||
|
|
echo ❌ Build failed!
|
||
|
|
pause
|
||
|
|
exit /b 1
|
||
|
|
)
|
||
|
|
echo ✅ Build completed
|
||
|
|
)
|
||
|
|
|
||
|
|
echo 📁 dist folder found
|
||
|
|
echo.
|
||
|
|
|
||
|
|
REM Check if port 3000 is already in use and kill the process
|
||
|
|
echo 🔍 Checking if port 3000 is in use...
|
||
|
|
set PORT_FREE=0
|
||
|
|
for /f "tokens=5" %%a in ('netstat -ano ^| findstr :3000 ^| findstr LISTENING') do (
|
||
|
|
set PID=%%a
|
||
|
|
echo ⚠️ Port 3000 is in use by process ID: %%a
|
||
|
|
echo Stopping process...
|
||
|
|
taskkill /F /PID %%a >nul 2>&1
|
||
|
|
if errorlevel 1 (
|
||
|
|
echo ❌ Failed to stop process. You may need to run as Administrator or manually kill the process.
|
||
|
|
echo Process ID: %%a
|
||
|
|
echo.
|
||
|
|
echo Please run this command manually as Administrator:
|
||
|
|
echo taskkill /F /PID %%a
|
||
|
|
echo.
|
||
|
|
pause
|
||
|
|
exit /b 1
|
||
|
|
)
|
||
|
|
timeout /t 2 /nobreak >nul
|
||
|
|
set PORT_FREE=1
|
||
|
|
)
|
||
|
|
|
||
|
|
REM Verify port is actually free
|
||
|
|
timeout /t 1 /nobreak >nul
|
||
|
|
for /f "tokens=5" %%a in ('netstat -ano ^| findstr :3000 ^| findstr LISTENING') do (
|
||
|
|
echo ❌ Port 3000 is still in use after kill attempt!
|
||
|
|
echo Please manually kill the process or restart your computer.
|
||
|
|
pause
|
||
|
|
exit /b 1
|
||
|
|
)
|
||
|
|
|
||
|
|
if %PORT_FREE%==1 (
|
||
|
|
echo ✅ Port 3000 freed!
|
||
|
|
) else (
|
||
|
|
echo ✅ Port 3000 is free
|
||
|
|
)
|
||
|
|
echo.
|
||
|
|
|
||
|
|
REM Start the server
|
||
|
|
echo 🌐 Starting server on http://localhost:3000
|
||
|
|
echo Press Ctrl+C to stop the server
|
||
|
|
echo.
|
||
|
|
node server/server.js
|
||
|
|
pause
|