14 lines
986 B
Batchfile
14 lines
986 B
Batchfile
@echo off
|
|
setlocal EnableDelayedExpansion
|
|
|
|
echo [Warmup] Waiting for nginx on port 8000...
|
|
powershell -NoProfile -Command ^
|
|
"$ok=0; for($i=0;$i -lt 120;$i++){try{$r=(Invoke-WebRequest 'http://localhost:8000/nginx-health' -TimeoutSec 2 -UseBasicParsing -ErrorAction Stop).StatusCode; if($r -eq 200){$ok=1;break}}catch{Start-Sleep -Milliseconds 500}}; if(!$ok){Write-Host '[Warmup] Timeout - server not ready.'; exit 1}"
|
|
if %errorlevel% neq 0 exit /b 1
|
|
|
|
echo [Warmup] Firing parallel requests to warm up all 8 PHP workers...
|
|
powershell -NoProfile -Command ^
|
|
"$urls=@('http://localhost:8000/admin/login','http://localhost:8000/admin','http://localhost:8000/'); $jobs=@(); 1..16|ForEach-Object{$u=$urls[($_ %% $urls.Count)]; $jobs+=Start-Job -ScriptBlock{param($u)try{Invoke-WebRequest $u -TimeoutSec 60 -UseBasicParsing -ErrorAction SilentlyContinue|Out-Null}catch{}} -ArgumentList $u}; $jobs|Wait-Job|Out-Null; $jobs|Remove-Job"
|
|
|
|
echo [Warmup] PHP OPcache warmed up successfully.
|