# 强制拉起 Nginx(避免 Restart-Service 挂死) $ErrorActionPreference = "Continue" Write-Output "=== before ===" Get-Service Nginx1.18 | Format-List Name, Status Get-Process nginx -EA SilentlyContinue | Format-Table Id,Path -AutoSize # 清僵尸 Get-Process nginx -EA SilentlyContinue | Stop-Process -Force -EA SilentlyContinue Start-Sleep -Seconds 1 # 先试 bounce if (Test-Path 'C:\yutongda\bounce_nginx.ps1') { try { & 'C:\yutongda\bounce_nginx.ps1' 2>&1 | ForEach-Object { "$_" } } catch { "BOUNCE_EX=$_" } } Start-Sleep -Seconds 2 $procs = @(Get-Process nginx -EA SilentlyContinue) Write-Output "AFTER_BOUNCE_COUNT=$($procs.Count)" if ($procs.Count -eq 0) { Write-Output "=== start nginx.exe directly ===" $ngx = 'C:\nginx-1.18.0\nginx.exe' $conf = 'C:\nginx-1.18.0\conf\nginx.conf' Start-Process -FilePath $ngx -ArgumentList @('-c', $conf) -WorkingDirectory 'C:\nginx-1.18.0' -WindowStyle Hidden Start-Sleep -Seconds 2 # 也试服务 try { Start-Service Nginx1.18 -ErrorAction Stop; "SERVICE_STARTED" } catch { "SERVICE_START_FAIL=$_" } } Write-Output "=== after ===" Get-Service Nginx1.18 | Format-List Name, Status Get-Process nginx -EA SilentlyContinue | Format-Table Id,Path -AutoSize netstat -ano | findstr ":443 " netstat -ano | findstr ":80 " Write-Output "=== curl ===" cmd /c "curl.exe -sk -H `"Host: ai.ytd-scm.com`" --connect-timeout 5 https://127.0.0.1/agent/health" Write-Output "" cmd /c "curl.exe -sk -o NUL -w root:%{http_code} -H `"Host: ai.ytd-scm.com`" --connect-timeout 5 https://127.0.0.1/" Write-Output "" cmd /c "curl.exe -sk -o NUL -w agent_direct:%{http_code} --connect-timeout 5 http://127.0.0.1:8910/health" Write-Output "" Write-Output "NGINX_START_DONE"