Vili/scripts/restart-vili-daemon.ps1
Meta Vens 3adb616497 Docs and launch scripts for the smoke deletion and the listen addresses
package.json loses the smoke script; the README and the service contract say no GET changes anything and name the listen addresses and the missing CORS; the launch and install scripts default -HostName to 127.0.0.1,10.77.0.4 instead of 0.0.0.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 03:09:22 +02:00

38 lines
1.3 KiB
PowerShell

param(
[int]$Port = 8824,
[string]$HostName = "127.0.0.1,10.77.0.4",
[string]$StateRoot = "E:\Projects\Vili\.vili"
)
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
$PidPath = Join-Path $StateRoot "vili-daemon.pid"
$TaskName = "GameCult\Vili"
if (Test-Path $PidPath) {
$existingPid = (Get-Content $PidPath -ErrorAction SilentlyContinue | Select-Object -First 1)
if ($existingPid) {
$process = Get-Process -Id ([int]$existingPid) -ErrorAction SilentlyContinue
if ($process) {
Stop-Process -Id $process.Id -Force
Start-Sleep -Seconds 1
}
}
}
if (Get-ScheduledTask -TaskName "Vili" -TaskPath "\GameCult\" -ErrorAction SilentlyContinue) {
Stop-ScheduledTask -TaskName "Vili" -TaskPath "\GameCult\" -ErrorAction SilentlyContinue
Start-Sleep -Seconds 1
Start-ScheduledTask -TaskName "Vili" -TaskPath "\GameCult\"
Start-Sleep -Seconds 3
node (Join-Path (Split-Path -Parent $PSScriptRoot) "scripts\vili-daemon.mjs") --health --host 127.0.0.1 --port $Port --state-root $StateRoot
if ($LASTEXITCODE -ne 0) {
throw "Vili scheduled task started but health check failed."
}
Write-Host "Vili restarted through scheduled task $TaskName"
} else {
& (Join-Path $PSScriptRoot "start-vili-daemon.ps1") `
-Port $Port `
-HostName $HostName `
-StateRoot $StateRoot
}