공개 런타임 워치독 창·복구 결함 3건 수정

재부팅 뒤 워치독이 5분마다 콘솔 창에 실패만 뿌리던 문제의 원인 세 가지를 고친다.

- 워치독이 DB 다운을 감지하고 직접 복구한다. postgres(vignette-dev-db) 기동은
  boot 담당이라 start-public-runtime.ps1 재호출로는 절대 복구되지 않았고, 그 결과
  워치독은 고칠 수 없는 대상에 start를 무한 재시도하며 실패만 기록했다. db를
  health check 항목에 넣고, 재시작 전에 컨테이너를 되살리며, 복구 실패 시에는
  runtime 재시작을 시도하지 않고 종료한다.
- 작업 액션을 wscript 런처(watch-public-runtime-task.vbs) 경유로 등록한다.
  powershell.exe를 직접 등록하면 -WindowStyle Hidden이어도 conhost 창이 매 실행
  번쩍이고, 5분 주기에서는 그것이 곧 화면을 가리는 창이 된다. 런처는 pin 인자를
  해석하지 않고 전달만 하며 provenance 검증은 기존대로 watchdog이 수행한다.
- boot이 web preview 상태를 보고 -SkipWebRestart를 조건부로 붙인다. 무조건 스킵하면
  재부팅 직후처럼 vite가 죽은 상태에서 boot 경로로는 web이 영영 복구되지 않았다.

hidden trigger는 액션이 wscript 런처를 거치는지 함께 검증하도록 맞췄다.
This commit is contained in:
Yun Chan 2026-08-12 21:17:04 +09:00
parent 80bcacc723
commit 5cb530e153
7 changed files with 184 additions and 28 deletions

View file

@ -28,6 +28,7 @@ param(
[int]$DbTimeoutSec = 90,
[int]$DbPort = 55432,
[int]$ApiPort = 8001,
[int]$WebPort = 5174,
[int]$EnginePort = 9099,
[int]$WhisperPort = 9882,
[int]$MeloTtsPort = 9883,
@ -225,6 +226,22 @@ function Test-VoiceApiHealthy {
return $false
}
function Test-WebPreviewHealthy {
# 재부팅 직후 web preview(vite)는 항상 죽어 있다. 이 검사 없이 무조건 -SkipWebRestart를
# 넘기면 boot 경로로는 web이 영원히 복구되지 않는다(2026-08-12 확인).
try {
$req = [System.Net.HttpWebRequest]::Create("http://127.0.0.1:$WebPort/")
$req.Timeout = 5000
$req.ReadWriteTimeout = 5000
$req.Proxy = $null
$resp = $req.GetResponse()
$resp.Close()
return $true
} catch {
return $false
}
}
function Test-VoiceSidecarStack {
$probeArgs = @(
"-X", "utf8", "-B", $voiceSidecarProbe,
@ -288,18 +305,29 @@ if (-not (Test-Tcp -Host_ "127.0.0.1" -Port $DbPort)) {
}
Write-BootLog "postgres 127.0.0.1:$DbPort up"
# 3) 엔진/API/cloudflared — 이미 healthy 면 스킵(불필요한 재시작/다운타임 방지)
if ((Test-ApiControlPlaneHealthy) -and (Test-EngineHealthy) -and (Test-VoiceApiHealthy) -and (Test-VoiceSidecarStack)) {
Write-BootLog "control plane, engine, exact local voice API, and sidecars already healthy; skipping runtime restart"
# 3) 엔진/API/web/cloudflared — 이미 healthy 면 스킵(불필요한 재시작/다운타임 방지)
# web preview는 살아 있을 때만 -SkipWebRestart 한다. 무조건 스킵하면 재부팅 직후처럼
# vite가 죽은 상태에서 boot 경로로는 web이 영영 복구되지 않는다.
$webHealthy = Test-WebPreviewHealthy
if ((Test-ApiControlPlaneHealthy) -and (Test-EngineHealthy) -and (Test-VoiceApiHealthy) -and (Test-VoiceSidecarStack) -and $webHealthy) {
Write-BootLog "control plane, engine, exact local voice API, sidecars, and web preview already healthy; skipping runtime restart"
} else {
Write-BootLog "running start-public-runtime.ps1 -SkipWebRestart"
$out = & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $startScript `
-Workspace $resolvedSourceRoot `
-Python $Python `
-EnginePort $EnginePort `
-WhisperPort $WhisperPort `
-MeloTtsPort $MeloTtsPort `
-SkipWebRestart 2>&1
$startArgs = @(
"-Workspace", $resolvedSourceRoot,
"-Python", $Python,
"-ApiPort", $ApiPort,
"-WebPort", $WebPort,
"-EnginePort", $EnginePort,
"-WhisperPort", $WhisperPort,
"-MeloTtsPort", $MeloTtsPort
)
if ($webHealthy) {
$startArgs += "-SkipWebRestart"
} else {
Write-BootLog "web preview down on 127.0.0.1:$WebPort; including web in restart"
}
Write-BootLog ("running start-public-runtime.ps1 " + ($startArgs -join " "))
$out = & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $startScript @startArgs 2>&1
$out | ForEach-Object { Write-BootLog (" pub> " + $_) }
if ($LASTEXITCODE -ne 0) {
Write-BootLog "ERROR: start-public-runtime.ps1 exit $LASTEXITCODE"