28 lines
791 B
Batchfile
28 lines
791 B
Batchfile
@echo off
|
|
setlocal
|
|
|
|
set "APP_DIR=%~dp0"
|
|
set "PORT=3000"
|
|
set "APP_URL=http://127.0.0.1:3000/"
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
|
"$ErrorActionPreference = 'Stop';" ^
|
|
"$appDir = $env:APP_DIR;" ^
|
|
"$port = [int]$env:PORT;" ^
|
|
"$url = $env:APP_URL;" ^
|
|
"$listener = Get-NetTCPConnection -LocalPort $port -State Listen -ErrorAction SilentlyContinue;" ^
|
|
"if (-not $listener) {" ^
|
|
" Start-Process -FilePath 'node' -ArgumentList 'server.mjs' -WorkingDirectory $appDir -WindowStyle Hidden;" ^
|
|
" Start-Sleep -Milliseconds 900;" ^
|
|
"}" ^
|
|
"Start-Process $url;"
|
|
|
|
if errorlevel 1 (
|
|
echo Fehler: Server konnte nicht gestartet oder Browser nicht geoeffnet werden.
|
|
echo Pruefe, ob Node.js installiert ist und Port %PORT% frei ist.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
endlocal
|