40 lines
1.8 KiB
PowerShell
40 lines
1.8 KiB
PowerShell
# 诊断并强制拉起 Nginx
|
|
$ErrorActionPreference = "Continue"
|
|
Set-Location 'C:\nginx-1.18.0'
|
|
|
|
Write-Output "=== nginx -t ==="
|
|
& .\nginx.exe -t 2>&1 | ForEach-Object { "$_" }
|
|
|
|
Write-Output "=== who owns 80/443 ==="
|
|
netstat -ano | findstr "LISTENING" | findstr ":80 "
|
|
netstat -ano | findstr "LISTENING" | findstr ":443 "
|
|
|
|
Write-Output "=== error.log tail ==="
|
|
$err = 'C:\nginx-1.18.0\logs\error.log'
|
|
if (Test-Path $err) { Get-Content $err -Tail 40 }
|
|
|
|
Write-Output "=== service config ==="
|
|
sc.exe qc Nginx1.18
|
|
sc.exe query Nginx1.18
|
|
|
|
Write-Output "=== try start with capture ==="
|
|
Remove-Item 'C:\nginx-1.18.0\logs\nginx-start.out.txt','C:\nginx-1.18.0\logs\nginx-start.err.txt' -Force -EA SilentlyContinue
|
|
$p = Start-Process -FilePath 'C:\nginx-1.18.0\nginx.exe' -WorkingDirectory 'C:\nginx-1.18.0' -PassThru -RedirectStandardOutput 'C:\nginx-1.18.0\logs\nginx-start.out.txt' -RedirectStandardError 'C:\nginx-1.18.0\logs\nginx-start.err.txt' -WindowStyle Hidden
|
|
Start-Sleep -Seconds 3
|
|
Write-Output "STARTED_PID=$($p.Id) HAS_EXITED=$($p.HasExited)"
|
|
if (Test-Path 'C:\nginx-1.18.0\logs\nginx-start.err.txt') { Get-Content 'C:\nginx-1.18.0\logs\nginx-start.err.txt' }
|
|
if (Test-Path 'C:\nginx-1.18.0\logs\nginx-start.out.txt') { Get-Content 'C:\nginx-1.18.0\logs\nginx-start.out.txt' }
|
|
Get-Process nginx -EA SilentlyContinue | Format-Table Id,Path -AutoSize
|
|
Get-Content $err -Tail 20
|
|
|
|
Write-Output "=== ai.conf root/admin exists? ==="
|
|
Test-Path 'E:\wwwroot\admin\dist\index.html'
|
|
Select-String -Path 'C:\nginx-1.18.0\myconf\ai.conf' -Pattern 'root |ssl_certificate' | ForEach-Object { $_.Line.Trim() }
|
|
Test-Path 'C:\nginx-1.18.0\cert\ai.ytd-scm.com.crt'
|
|
Test-Path 'C:\nginx-1.18.0\cert\ai.ytd-scm.com.key'
|
|
|
|
Write-Output "=== main nginx.conf includes ==="
|
|
Select-String -Path 'C:\nginx-1.18.0\conf\nginx.conf' -Pattern 'include|myconf' | ForEach-Object { $_.Line.Trim() }
|
|
|
|
Write-Output "DIAG_DONE"
|