79 lines
4.4 KiB
Batchfile
79 lines
4.4 KiB
Batchfile
@echo off
|
|
setlocal EnableDelayedExpansion
|
|
chcp 65001 >nul 2>&1
|
|
|
|
echo.
|
|
echo ============================================================
|
|
echo Matab Startup Diagnostics
|
|
echo ============================================================
|
|
echo.
|
|
|
|
REM --- [1] Service Status ---
|
|
echo [1] Service Status:
|
|
for %%S in (MatabPHPCgi MatabAutostart) do (
|
|
sc query %%S 2>nul | find "RUNNING" >nul
|
|
if !errorlevel! equ 0 (
|
|
echo %%S [RUNNING]
|
|
) else (
|
|
sc query %%S 2>nul | find "STOPPED" >nul
|
|
if !errorlevel! equ 0 (
|
|
echo %%S [STOPPED]
|
|
) else (
|
|
echo %%S [NOT INSTALLED]
|
|
)
|
|
)
|
|
)
|
|
echo.
|
|
|
|
REM --- [2] Port Check ---
|
|
echo [2] Port Availability:
|
|
powershell -NoProfile -Command ^
|
|
"foreach($p in @(8000,9001)){try{$t=New-Object Net.Sockets.TcpClient;$t.Connect('127.0.0.1',$p);$t.Close();Write-Host (' Port ' + $p + ' [OPEN]')}catch{Write-Host (' Port ' + $p + ' [CLOSED]')}}"
|
|
echo.
|
|
|
|
REM --- [3] Nginx health (no PHP) ---
|
|
echo [3] Nginx response time (no PHP):
|
|
powershell -NoProfile -Command ^
|
|
"try{$sw=[Diagnostics.Stopwatch]::StartNew();$r=Invoke-WebRequest 'http://localhost:8000/nginx-health' -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop;$sw.Stop();Write-Host (' ' + $sw.ElapsedMilliseconds + ' ms (status ' + $r.StatusCode + ')')}catch{Write-Host ' FAILED - nginx not responding'}"
|
|
echo.
|
|
|
|
REM --- [4] First PHP request timing ---
|
|
echo [4] First PHP request time (cold = slow, warm = fast):
|
|
powershell -NoProfile -Command ^
|
|
"$sw=[Diagnostics.Stopwatch]::StartNew(); try{ $r=Invoke-WebRequest 'http://localhost:8000/admin/login' -TimeoutSec 30 -UseBasicParsing -MaximumRedirection 5 -ErrorAction SilentlyContinue; $sw.Stop(); $ms=$sw.ElapsedMilliseconds; $label=if($ms -lt 800){'[FAST]'}elseif($ms -lt 3000){'[OK - warming up]'}else{'[SLOW - OPcache cold]'}; Write-Host (' ' + $ms + ' ms status=' + $r.StatusCode + ' ' + $label) }catch{ $sw.Stop(); Write-Host (' FAILED after ' + $sw.ElapsedMilliseconds + ' ms err=' + $_.Exception.Message) }"
|
|
echo.
|
|
|
|
REM --- [5] Second PHP request timing (should be faster) ---
|
|
echo [5] Second PHP request time (OPcache should kick in):
|
|
powershell -NoProfile -Command ^
|
|
"$sw=[Diagnostics.Stopwatch]::StartNew(); try{ $r=Invoke-WebRequest 'http://localhost:8000/admin/login' -TimeoutSec 30 -UseBasicParsing -MaximumRedirection 5 -ErrorAction SilentlyContinue; $sw.Stop(); $ms=$sw.ElapsedMilliseconds; $label=if($ms -lt 500){'[FAST - OPcache working]'}elseif($ms -lt 1500){'[OK]'}else{'[SLOW - problem]'}; Write-Host (' ' + $ms + ' ms status=' + $r.StatusCode + ' ' + $label) }catch{ $sw.Stop(); Write-Host (' FAILED after ' + $sw.ElapsedMilliseconds + ' ms err=' + $_.Exception.Message) }"
|
|
echo.
|
|
|
|
REM --- [6] PHP process count ---
|
|
echo [6] PHP worker processes:
|
|
powershell -NoProfile -Command ^
|
|
"$procs=Get-Process php-cgi -ErrorAction SilentlyContinue;if($procs){Write-Host (' ' + $procs.Count + ' php-cgi processes running (expected: 9 = 1 master + 8 children)')}else{Write-Host ' No php-cgi processes found!'}"
|
|
echo.
|
|
|
|
REM --- [7] OPcache file cache ---
|
|
echo [7] OPcache file cache on disk:
|
|
powershell -NoProfile -Command ^
|
|
"if(Test-Path 'C:\tmp\php-opcache'){$files=(Get-ChildItem 'C:\tmp\php-opcache' -Recurse -File -ErrorAction SilentlyContinue).Count;$size=[math]::Round((Get-ChildItem 'C:\tmp\php-opcache' -Recurse -File -ErrorAction SilentlyContinue|Measure-Object -Property Length -Sum).Sum/1MB,1);Write-Host (' ' + $files + ' files, ' + $size + ' MB cached')}else{Write-Host ' Directory not found (C:\tmp\php-opcache)'}"
|
|
echo.
|
|
|
|
REM --- [8] Warmup task status ---
|
|
echo [8] MatabWarmup scheduled task:
|
|
powershell -NoProfile -Command ^
|
|
"try{$t=Get-ScheduledTask -TaskName 'MatabWarmup' -ErrorAction Stop;$info=Get-ScheduledTaskInfo -TaskName 'MatabWarmup' -ErrorAction SilentlyContinue;$last=if($info.LastRunTime){$info.LastRunTime.ToString('yyyy-MM-dd HH:mm:ss')}else{'never'};Write-Host (' State: ' + $t.State + ' | Last run: ' + $last + ' | Last result: ' + $info.LastTaskResult)}catch{Write-Host ' Task not found - run install.bat'}"
|
|
echo.
|
|
|
|
echo ============================================================
|
|
echo Interpretation:
|
|
echo - If [4] ^> 3000ms and [5] ^< 1000ms: OPcache warming up normally
|
|
echo - If both [4] and [5] are slow: PHP or DB issue
|
|
echo - If port 9001 CLOSED: MatabPHPCgi service failed
|
|
echo - If nginx-health fails but port 8000 open: nginx config error
|
|
echo ============================================================
|
|
echo.
|
|
pause
|