Skip to content

Commit 7aebdee

Browse files
committed
ci(windows): redirect redis logs and capture pid for debugging
1 parent 71a6524 commit 7aebdee

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

.github/workflows/unittest-windows-debug.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ jobs:
5454
Write-Host "redis-server executable: $exe"
5555
if (-not $exe) { Write-Error "redis-server not found; cannot start"; exit 1 }
5656
# Start redis, bind both IPv4 and IPv6 addresses to reduce localhost mismatch
57-
Start-Process -FilePath $exe -ArgumentList '--port 6379 --bind 127.0.0.1 ::1' -NoNewWindow
58-
Write-Host "Started redis-server, waiting for it to accept connections..."
57+
$outFile = Join-Path $env:RUNNER_TEMP 'redis.stdout.log'
58+
$errFile = Join-Path $env:RUNNER_TEMP 'redis.stderr.log'
59+
Write-Host "Redirecting redis stdout to: $outFile"
60+
Write-Host "Redirecting redis stderr to: $errFile"
61+
$proc = Start-Process -FilePath $exe -ArgumentList '--port 6379 --bind 127.0.0.1 ::1' -RedirectStandardOutput $outFile -RedirectStandardError $errFile -WindowStyle Hidden -PassThru
62+
Write-Host "Started redis-server (pid=$($proc.Id)), waiting for it to accept connections..."
5963
$ok = $false
6064
for ($i=0; $i -lt 30; $i++) {
6165
Start-Sleep -Seconds 1
@@ -69,12 +73,13 @@ jobs:
6973
if ($tnc -and $tnc.TcpTestSucceeded) { $ok = $true; break }
7074
} catch {}
7175
}
72-
if (-not $ok) {
76+
if (-not $ok) {
7377
Write-Host "=== Redis failed to become reachable; dumping diagnostics ==="
78+
Get-Process -Id $proc.Id -ErrorAction SilentlyContinue | Format-Table -AutoSize
7479
Get-Process -Name redis* -ErrorAction SilentlyContinue | Format-Table -AutoSize
7580
netstat -ano | Select-String ":6379"
76-
if (Test-Path "$env:USERPROFILE\redis.out") { Get-Content "$env:USERPROFILE\redis.out" -ErrorAction SilentlyContinue | Select-Object -Last 200 }
77-
if (Test-Path "$env:USERPROFILE\redis.err") { Get-Content "$env:USERPROFILE\redis.err" -ErrorAction SilentlyContinue | Select-Object -Last 200 }
81+
if (Test-Path $outFile) { Write-Host "--- redis stdout ---"; Get-Content $outFile -ErrorAction SilentlyContinue | Select-Object -Last 200 }
82+
if (Test-Path $errFile) { Write-Host "--- redis stderr ---"; Get-Content $errFile -ErrorAction SilentlyContinue | Select-Object -Last 200 }
7883
Write-Error "redis did not start or accept connections"
7984
}
8085
Write-Host "redis is up"

0 commit comments

Comments
 (0)