fix(web): port check, process isolation, startup diagnostics

- web-publish: check port availability before starting, show which process
  holds it; run httpd -t on startup failure for diagnostics
- All scripts: filter httpd processes by path (Resolve-Path match) to avoid
  killing or misidentifying a global Apache installation
- web-info: warn about foreign httpd processes
- web-stop: only stop our Apache instance

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-02-22 16:38:53 +03:00
parent e2f765fcc0
commit b68013b2f2
4 changed files with 84 additions and 18 deletions
+15 -4
View File
@@ -46,14 +46,25 @@ if (-not (Test-Path $httpdExe)) {
exit 0
}
# --- Check process ---
$httpdProc = Get-Process httpd -ErrorAction SilentlyContinue
if ($httpdProc) {
$pids = ($httpdProc | ForEach-Object { $_.Id }) -join ", "
# --- Check process (only our Apache) ---
$httpdExeNorm = (Resolve-Path $httpdExe -ErrorAction SilentlyContinue).Path
$ourProc = Get-Process httpd -ErrorAction SilentlyContinue | Where-Object {
try { $_.Path -eq $httpdExeNorm } catch { $false }
}
$foreignProc = Get-Process httpd -ErrorAction SilentlyContinue | Where-Object {
try { $_.Path -ne $httpdExeNorm } catch { $true }
}
if ($ourProc) {
$pids = ($ourProc | ForEach-Object { $_.Id }) -join ", "
Write-Host "Status: Запущен (PID: $pids)" -ForegroundColor Green
} else {
Write-Host "Status: Остановлен" -ForegroundColor Yellow
}
if ($foreignProc) {
$fpid = ($foreignProc | Select-Object -First 1).Id
$fpath = try { ($foreignProc | Select-Object -First 1).Path } catch { "?" }
Write-Host "[WARN] Обнаружен сторонний Apache (PID: $fpid, $fpath)" -ForegroundColor Yellow
}
Write-Host "Path: $ApachePath"