matab-panel/scripts/start-now.bat

19 lines
1010 B
Batchfile

@echo off
setlocal
set "SCRIPTS_DIR=%~dp0"
set "SCRIPTS_DIR=%SCRIPTS_DIR:~0,-1%"
for %%F in ("%SCRIPTS_DIR%\..") do set "PROJECT_DIR=%%~fF"
echo Checking port 8000...
powershell -NoProfile -Command ^
"if((Test-NetConnection -ComputerName localhost -Port 8000 -WarningAction SilentlyContinue).TcpTestSucceeded){Write-Host 'Already running on http://localhost:8000';exit 0}else{Write-Host 'Not running. Starting...';exit 1}"
if %errorLevel% equ 0 (
start "" "http://localhost:8000"
exit /b 0
)
wscript.exe "%SCRIPTS_DIR%\start-server.vbs"
echo Waiting for server to be ready...
powershell -NoProfile -Command "$max=30; $i=0; $ok=$false; while($i -lt $max){ try{ $t=New-Object Net.Sockets.TcpClient; $t.Connect('127.0.0.1',8000); $t.Close(); Write-Host '[OK] Server ready: http://localhost:8000'; Start-Process 'http://localhost:8000'; $ok=$true; break }catch{ $i++; Start-Sleep -Milliseconds 500 } }; if(-not $ok){ Write-Host '[FAIL] Server did not start. Check: %SCRIPTS_DIR%\server.log' }"
pause