공개 런타임 워치독 창·복구 결함 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

@ -20,6 +20,7 @@ $installerScript = Join-Path $resolvedSourceRoot "scripts\install-public-runtime
$watchScript = Join-Path $resolvedSourceRoot "scripts\watch-public-runtime.ps1"
$startScript = Join-Path $resolvedSourceRoot "scripts\start-public-runtime.ps1"
$voiceSidecarProbe = Join-Path $resolvedSourceRoot "scripts\probe-public-voice-sidecars.py"
$taskLauncher = Join-Path $resolvedSourceRoot "scripts\watch-public-runtime-task.vbs"
function Invoke-GitText {
param([string[]]$Arguments)
@ -31,7 +32,7 @@ function Invoke-GitText {
return (@($value) -join [Environment]::NewLine).Trim()
}
foreach ($requiredScript in @($installerScript, $watchScript, $startScript, $voiceSidecarProbe)) {
foreach ($requiredScript in @($installerScript, $watchScript, $startScript, $voiceSidecarProbe, $taskLauncher)) {
if (!(Test-Path -LiteralPath $requiredScript -PathType Leaf)) {
throw "Public runtime script not found at $requiredScript"
}
@ -73,7 +74,8 @@ foreach ($relativePath in @(
"scripts/install-public-runtime-task.ps1",
"scripts/watch-public-runtime.ps1",
"scripts/start-public-runtime.ps1",
"scripts/probe-public-voice-sidecars.py"
"scripts/probe-public-voice-sidecars.py",
"scripts/watch-public-runtime-task.vbs"
)) {
Invoke-GitText -Arguments @("ls-files", "--error-unmatch", "--", $relativePath) | Out-Null
}
@ -83,12 +85,16 @@ $sourceTree = Invoke-GitText -Arguments @("rev-parse", "--verify", "HEAD^{tree}"
$watchdogSha256 = (Get-FileHash -LiteralPath $watchScript -Algorithm SHA256).Hash.ToLowerInvariant()
$startScriptSha256 = (Get-FileHash -LiteralPath $startScript -Algorithm SHA256).Hash.ToLowerInvariant()
$powershell = (Get-Command powershell.exe).Source
$wscript = Join-Path $env:SystemRoot "System32\wscript.exe"
if (!(Test-Path -LiteralPath $wscript -PathType Leaf)) {
throw "wscript.exe not found at $wscript"
}
$userId = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
# powershell.exe 를 액션으로 직접 등록하면 -WindowStyle Hidden 이어도 conhost 창이
# 매 실행 번쩍인다. 5분 주기 워치독에서는 그게 곧 "5분마다 뜨는 창"이 된다.
# wscript 런처를 거쳐 Run(cmd, 0) 으로 띄우면 창이 생성되지 않는다.
$actionArguments = @(
"-NoProfile",
"-ExecutionPolicy Bypass",
"-File `"$watchScript`"",
"-StableSourceRoot `"$resolvedSourceRoot`"",
"-ExpectedSourceCommit $sourceCommit",
@ -108,8 +114,8 @@ if ($AdditionalPublicHealthUrls.Count -gt 0) {
}
$action = New-ScheduledTaskAction `
-Execute $powershell `
-Argument ($actionArguments -join " ") `
-Execute $wscript `
-Argument ("`"$taskLauncher`" " + ($actionArguments -join " ")) `
-WorkingDirectory $resolvedSourceRoot
$logonTrigger = New-ScheduledTaskTrigger -AtLogOn -User $userId
@ -144,7 +150,7 @@ $task = New-ScheduledTask `
Register-ScheduledTask -TaskName $TaskName -InputObject $task -Force | Out-Null
Write-Output "Installed scheduled task '$TaskName' for $userId"
Write-Output "Action: $powershell $($actionArguments -join ' ')"
Write-Output "Action: $wscript `"$taskLauncher`" $($actionArguments -join ' ')"
Write-Output "Pinned source: root=$resolvedSourceRoot commit=$sourceCommit tree=$sourceTree"
Write-Output "Pinned scripts: watchdog_sha256=$watchdogSha256 start_sha256=$startScriptSha256"
Write-Output "Interval: every $IntervalMinutes minute(s), plus at user logon"