Make Muninn publish live Idunn RUDP health
This commit is contained in:
parent
f30274f3de
commit
95bbb307db
5 changed files with 183 additions and 24 deletions
|
|
@ -198,6 +198,7 @@ fn serve(options: Options) -> Result<()> {
|
|||
let mut move_evidence_stream = create_move_evidence_stream(&options)?;
|
||||
let mut active_move_lights = Vec::new();
|
||||
let mut last_default_move_light_write_at = None;
|
||||
let mut last_idunn_health_publish_attempt_at = None;
|
||||
let mut active_move_states: Vec<ActiveMoveStateSource> = options
|
||||
.move_state_sources
|
||||
.iter()
|
||||
|
|
@ -230,6 +231,11 @@ fn serve(options: Options) -> Result<()> {
|
|||
)?;
|
||||
publish_quest_access_if_requested(&mut node, &options)?;
|
||||
publish_surface(&mut node, &options, "idle", &[])?;
|
||||
publish_daemon_health_if_configured(
|
||||
&options,
|
||||
&node,
|
||||
&mut last_idunn_health_publish_attempt_at,
|
||||
)?;
|
||||
let has_platform_default_move_lights = platform_default_move_lights_enabled();
|
||||
if options.interval_seconds.is_none()
|
||||
&& active_move_lights.is_empty()
|
||||
|
|
@ -2014,6 +2020,10 @@ fn health_check(options: &Options) -> Result<()> {
|
|||
|
||||
fn evaluate_health(options: &Options) -> Result<String> {
|
||||
let node = open_node(options, "muninn-health")?;
|
||||
evaluate_health_from_node(options, &node)
|
||||
}
|
||||
|
||||
fn evaluate_health_from_node(options: &Options, node: &cultmesh_rs::CultMeshNode) -> Result<String> {
|
||||
let surface = node
|
||||
.get_required::<MuninnTelemetrySurfaceRecord>("latest")
|
||||
.context("Muninn telemetry surface is unavailable")?;
|
||||
|
|
@ -2033,6 +2043,39 @@ fn evaluate_health(options: &Options) -> Result<String> {
|
|||
))
|
||||
}
|
||||
|
||||
fn publish_daemon_health_if_configured(
|
||||
options: &Options,
|
||||
node: &cultmesh_rs::CultMeshNode,
|
||||
last_attempt_at: &mut Option<Instant>,
|
||||
) -> Result<()> {
|
||||
let Some(idunn) = options.idunn_rudp_health.as_ref() else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let cadence = Duration::from_secs(options.interval_seconds.unwrap_or(15).max(1));
|
||||
if last_attempt_at
|
||||
.as_ref()
|
||||
.is_some_and(|instant| instant.elapsed() < cadence)
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let observed_at = idunn_timestamp()?;
|
||||
let health = evaluate_health_from_node(options, node);
|
||||
let (state, detail) = match health {
|
||||
Ok(detail) => ("active", detail),
|
||||
Err(error) => ("failed", error.to_string()),
|
||||
};
|
||||
*last_attempt_at = Some(Instant::now());
|
||||
if let Err(error) = publish_idunn_rudp_health(idunn, state, &detail, &observed_at) {
|
||||
eprintln!(
|
||||
"Muninn could not publish Idunn RUDP health for {} at {}: {error:#}",
|
||||
options.host_id, observed_at
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn publish_idunn_rudp_health(
|
||||
options: &IdunnRudpHealthOptions,
|
||||
state: &str,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ microphones, cameras, and future sensors.
|
|||
|
||||
```powershell
|
||||
cargo build -p muninn-daemon
|
||||
muninn serve --store C:\Meta\Odin\state\muninn.telemetry.cc --interval-seconds 15
|
||||
muninn serve --store C:\Meta\Odin\state\muninn.telemetry.cc --interval-seconds 15 --idunn-rudp-health 127.0.0.1:17870 --idunn-daemon starfire-muninn --idunn-health-contract muninn.cultnet-rudp-local-telemetry-and-quest-access
|
||||
muninn --health --store C:\Meta\Odin\state\muninn.telemetry.cc
|
||||
```
|
||||
|
||||
|
|
@ -97,8 +97,13 @@ E:\Projects\Odin\scripts\restart-starfire-muninn.cmd
|
|||
E:\Projects\Odin\scripts\health-starfire-muninn.cmd
|
||||
```
|
||||
|
||||
The restart script launches Muninn hidden with `--host starfire --quest-adb`
|
||||
and stores state in `C:\Meta\Odin\state\starfire.muninn.telemetry.cc`.
|
||||
The restart script launches Muninn hidden with `--host starfire --quest-adb`,
|
||||
`--idunn-rudp-health 127.0.0.1:17870`, `--idunn-daemon starfire-muninn`, and
|
||||
`--idunn-health-contract muninn.cultnet-rudp-local-telemetry-and-quest-access`.
|
||||
If the CultCache store at `C:\Meta\Odin\state\starfire.muninn.telemetry.cc`
|
||||
fails MessagePack decode on boot, the restart path archives the corrupt file,
|
||||
clears the stale `.lock`, and relaunches the daemon instead of leaving the lane
|
||||
dead.
|
||||
|
||||
The deployed loopback helper must accept Muninn's command contract:
|
||||
|
||||
|
|
@ -186,11 +191,11 @@ muninn move-light-status \
|
|||
Idunn keeps the Muninn daemon alive. Idunn does not learn a Move-specific
|
||||
watcher, and Mimir does not write HID directly except through temporary smoke
|
||||
scripts used to prove hardware behavior before a Muninn daemon is available.
|
||||
In `--health` mode, Muninn can also publish `idunn.daemon_health` directly to
|
||||
Idunn over `cultnet.transport.rudp.v0` with `--idunn-rudp-health`,
|
||||
`--idunn-daemon`, and `--idunn-health-contract`. Starfire uses this path for
|
||||
the `starfire-muninn` target; the command probe remains compatibility evidence,
|
||||
not daemon truth.
|
||||
When `serve` is launched with `--idunn-rudp-health`, `--idunn-daemon`, and
|
||||
`--idunn-health-contract`, the long-running Muninn body publishes
|
||||
`idunn.daemon_health` directly to Idunn over `cultnet.transport.rudp.v0` on its
|
||||
normal cadence. `--health` keeps the same publication path for manual proof and
|
||||
compatibility probes, but the live owner is the daemon's `serve` process.
|
||||
Quest ADB probing is a telemetry input, not daemon liveness. If `adb` is
|
||||
missing or the Quest is unavailable, Muninn publishes `muninn.quest_access` as
|
||||
`unavailable` and keeps serving the local telemetry surface.
|
||||
|
|
@ -204,7 +209,10 @@ action and `start-muninn-serve-hidden.vbs` as its argument. It also repairs
|
|||
hidden VBS launchers directly when those compatibility commands exist on Raven.
|
||||
The serve VBS launches `start-muninn-serve.ps1` with noninteractive hidden
|
||||
PowerShell. The PowerShell launcher starts `muninn.exe` with
|
||||
`-WindowStyle Hidden` and redirects logs under `C:\Meta\Odin\logs\muninn`.
|
||||
`-WindowStyle Hidden`, passes `--idunn-rudp-health 10.77.0.2:17870`,
|
||||
`--idunn-daemon muninn`, and
|
||||
`--idunn-health-contract muninn.cultnet-rudp-remote-telemetry-health`, and
|
||||
redirects logs under `C:\Meta\Odin\logs\muninn`.
|
||||
Raven is an operator-consented host: Muninn operations on Raven must be
|
||||
background-only and must not create visible terminal windows. `.cmd` files may
|
||||
exist only as manual compatibility trampolines; Task Scheduler must execute
|
||||
|
|
@ -225,6 +233,9 @@ actuators only, not lifecycle owners. The binary is installed at
|
|||
`/home/metacrat/.local/state/gamecult/muninn/muninn.telemetry.cc`, and the
|
||||
restart actuator launches `serve --host nightwing --interval-seconds 15` with
|
||||
`--move-state move-usb=/dev/input/by-id/usb-Sony_Computer_Entertainment_Motion_Controller-joystick`,
|
||||
`--idunn-rudp-health 10.77.0.2:17870`,
|
||||
`--idunn-daemon nightwing-muninn`,
|
||||
`--idunn-health-contract muninn.cultnet-rudp-remote-telemetry-and-move-hid`,
|
||||
PID, and logs under
|
||||
`/home/metacrat/.local/state/gamecult/muninn`.
|
||||
With that Move state source attached, `serve` also publishes the
|
||||
|
|
@ -236,4 +247,5 @@ separate `/dev/input/js*` paths; `nightwing-move-state-sources.sh` prefers the
|
|||
Bluetooth `HID_ID=0005:0000054C:000003D5` path so Idunn health does not demand
|
||||
fresh records from two faces of the same controller. The Nightwing health
|
||||
actuator publishes `nightwing-muninn` health over RUDP to Starfire Idunn at
|
||||
`10.77.0.2:17870`.
|
||||
`10.77.0.2:17870`, but that command is fallback proof only; the live keepalive
|
||||
contract is now published by the long-running Nightwing `serve` process.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ param(
|
|||
[string] $RavenHost = "raven",
|
||||
[string] $MuninnExe = "C:\Meta\Odin\Muninn\muninn.exe",
|
||||
[string] $StorePath = "C:\Meta\Odin\state\muninn.telemetry.cc",
|
||||
[string] $LogRoot = "C:\Meta\Odin\logs\muninn"
|
||||
[string] $LogRoot = "C:\Meta\Odin\logs\muninn",
|
||||
[string] $IdunnRudpHealth = "10.77.0.2:17870",
|
||||
[string] $IdunnDaemon = "muninn",
|
||||
[string] $IdunnHealthContract = "muninn.cultnet-rudp-remote-telemetry-health"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
|
@ -32,7 +35,7 @@ New-Item -ItemType Directory -Force -Path (Split-Path -Parent "$StorePath") | Ou
|
|||
`$psLines = @(
|
||||
'`$ErrorActionPreference = "Stop"',
|
||||
'`$ProgressPreference = "SilentlyContinue"',
|
||||
'`$process = Start-Process -FilePath "$MuninnExe" -ArgumentList @("serve", "--store", "$StorePath", "--log-root", "$LogRoot", "--host", "raven", "--interval-seconds", "15") -WindowStyle Hidden -PassThru -RedirectStandardOutput "$LogRoot\muninn-serve.out.log" -RedirectStandardError "$LogRoot\muninn-serve.err.log"',
|
||||
'`$process = Start-Process -FilePath "$MuninnExe" -ArgumentList @("serve", "--store", "$StorePath", "--log-root", "$LogRoot", "--host", "raven", "--interval-seconds", "15", "--idunn-rudp-health", "$IdunnRudpHealth", "--idunn-daemon", "$IdunnDaemon", "--idunn-health-contract", "$IdunnHealthContract") -WindowStyle Hidden -PassThru -RedirectStandardOutput "$LogRoot\muninn-serve.out.log" -RedirectStandardError "$LogRoot\muninn-serve.err.log"',
|
||||
'`$process.Id | Set-Content -Encoding ASCII -LiteralPath "$LogRoot\muninn-serve.pid"'
|
||||
)
|
||||
Set-Content -LiteralPath `$psLauncher -Value `$psLines -Encoding ASCII
|
||||
|
|
@ -120,6 +123,25 @@ Assert-HiddenVbsTask -TaskName "GameCult-Muninn" -VbsPath `$vbsLauncher
|
|||
Assert-HiddenVbsTask -TaskName "GameCult-Muninn-Activate" -VbsPath `$activateVbs
|
||||
Assert-HiddenVbsTask -TaskName "GameCult-Muninn-VideoProof" -VbsPath `$videoProofVbs
|
||||
Start-ScheduledTask -TaskName "GameCult-Muninn"
|
||||
Start-Sleep -Seconds 2
|
||||
`$process = Get-CimInstance Win32_Process |
|
||||
Where-Object { `$_.Name -ieq "muninn.exe" -and `$_.CommandLine -like "*serve*" -and `$_.CommandLine -like "*--host*raven*" } |
|
||||
Select-Object -First 1
|
||||
if (`$null -eq `$process) {
|
||||
throw "Muninn serve process is not running on Raven"
|
||||
}
|
||||
foreach (`$pattern in @(
|
||||
"--idunn-rudp-health",
|
||||
"$IdunnRudpHealth",
|
||||
"--idunn-daemon",
|
||||
"$IdunnDaemon",
|
||||
"--idunn-health-contract",
|
||||
"$IdunnHealthContract"
|
||||
)) {
|
||||
if (`$process.CommandLine -notlike "*`$pattern*") {
|
||||
throw "Muninn Raven serve command line is missing `${pattern}: `$(`$process.CommandLine)"
|
||||
}
|
||||
}
|
||||
"@
|
||||
|
||||
$uploadId = [guid]::NewGuid().ToString("N")
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ param(
|
|||
[string] $LogRoot = "/home/metacrat/.local/state/gamecult/muninn",
|
||||
[string[]] $MoveState = @(),
|
||||
[string] $MoveEvidenceStream = "muninn:nightwing:move-evidence",
|
||||
[int] $IntervalSeconds = 15
|
||||
[int] $IntervalSeconds = 15,
|
||||
[string] $IdunnRudpHealth = "10.77.0.2:17870",
|
||||
[string] $IdunnDaemon = "nightwing-muninn",
|
||||
[string] $IdunnHealthContract = "muninn.cultnet-rudp-remote-telemetry-and-move-hid"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
|
@ -47,7 +50,10 @@ set -- serve \
|
|||
$moveStateSetLines
|
||||
set -- "`$@" \
|
||||
--move-evidence-stream '$MoveEvidenceStream' \
|
||||
--interval-seconds '$IntervalSeconds'
|
||||
--interval-seconds '$IntervalSeconds' \
|
||||
--idunn-rudp-health '$IdunnRudpHealth' \
|
||||
--idunn-daemon '$IdunnDaemon' \
|
||||
--idunn-health-contract '$IdunnHealthContract'
|
||||
nohup '$MuninnExe' "`$@" \
|
||||
> '$LogRoot/muninn-serve.out.log' \
|
||||
2> '$LogRoot/muninn-serve.err.log' \
|
||||
|
|
@ -55,6 +61,10 @@ nohup '$MuninnExe' "`$@" \
|
|||
echo `$! > '$LogRoot/muninn.pid'
|
||||
sleep 1
|
||||
kill -0 "`$(cat '$LogRoot/muninn.pid')" 2>/dev/null
|
||||
if ! pgrep -af '[m]uninn serve .*--host nightwing' | grep -F -- '--idunn-rudp-health $IdunnRudpHealth' >/dev/null 2>&1; then
|
||||
echo 'Nightwing Muninn serve command line is missing Idunn RUDP health arguments' >&2
|
||||
exit 1
|
||||
fi
|
||||
"@
|
||||
|
||||
ssh.exe -o BatchMode=yes -o ConnectTimeout=5 $SshTarget $remoteScript
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ param(
|
|||
[string] $QuestSerial = "1WMHHB68PG1515",
|
||||
[string] $MoveBluetoothHost = "5C:93:A2:9C:A8:A8",
|
||||
[string[]] $MoveState = @(),
|
||||
[switch] $EnableUsbMoveState
|
||||
[switch] $EnableUsbMoveState,
|
||||
[string] $IdunnRudpHealth = "127.0.0.1:17870",
|
||||
[string] $IdunnDaemon = "starfire-muninn",
|
||||
[string] $IdunnHealthContract = "muninn.cultnet-rudp-local-telemetry-and-quest-access"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
|
@ -41,7 +44,10 @@ $arguments = @(
|
|||
"--host", "starfire",
|
||||
"--interval-seconds", "15",
|
||||
"--quest-adb",
|
||||
"--quest-serial", $QuestSerial
|
||||
"--quest-serial", $QuestSerial,
|
||||
"--idunn-rudp-health", $IdunnRudpHealth,
|
||||
"--idunn-daemon", $IdunnDaemon,
|
||||
"--idunn-health-contract", $IdunnHealthContract
|
||||
)
|
||||
foreach ($source in $MoveState) {
|
||||
if (-not [string]::IsNullOrWhiteSpace($source)) {
|
||||
|
|
@ -52,17 +58,83 @@ if ($EnableUsbMoveState) {
|
|||
$arguments += @("--move-state", "move-starfire-usb=windows-psmove")
|
||||
}
|
||||
|
||||
$process = Start-Process `
|
||||
-FilePath $MuninnExe `
|
||||
-ArgumentList $arguments `
|
||||
-WindowStyle Hidden `
|
||||
-PassThru `
|
||||
-RedirectStandardOutput (Join-Path $LogRoot "muninn-serve.out.log") `
|
||||
-RedirectStandardError (Join-Path $LogRoot "muninn-serve.err.log")
|
||||
$serveOutLog = Join-Path $LogRoot "muninn-serve.out.log"
|
||||
$serveErrLog = Join-Path $LogRoot "muninn-serve.err.log"
|
||||
$pidPath = Join-Path $LogRoot "muninn-serve.pid"
|
||||
$lockPath = "$StorePath.lock"
|
||||
|
||||
$process.Id | Set-Content -Encoding ASCII -LiteralPath (Join-Path $LogRoot "muninn-serve.pid")
|
||||
function Start-MuninnServeProcess {
|
||||
param([string[]] $ArgumentList)
|
||||
|
||||
$process = Start-Process `
|
||||
-FilePath $MuninnExe `
|
||||
-ArgumentList $ArgumentList `
|
||||
-WindowStyle Hidden `
|
||||
-PassThru `
|
||||
-RedirectStandardOutput $serveOutLog `
|
||||
-RedirectStandardError $serveErrLog
|
||||
$process.Id | Set-Content -Encoding ASCII -LiteralPath $pidPath
|
||||
return $process
|
||||
}
|
||||
|
||||
function Get-StarfireMuninnServeProcess {
|
||||
return Get-CimInstance Win32_Process |
|
||||
Where-Object {
|
||||
$_.Name -ieq "muninn.exe" -and
|
||||
$_.CommandLine -like "*serve*" -and
|
||||
$_.CommandLine -like "*--host*starfire*"
|
||||
} |
|
||||
Select-Object -First 1
|
||||
}
|
||||
|
||||
function Reset-CorruptMuninnStore {
|
||||
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||
if (Test-Path -LiteralPath $StorePath) {
|
||||
Move-Item -LiteralPath $StorePath -Destination "$StorePath.corrupt-$timestamp" -Force
|
||||
}
|
||||
Remove-Item -LiteralPath $lockPath -Force -ErrorAction SilentlyContinue
|
||||
$storeLeaf = Split-Path -Leaf $StorePath
|
||||
Get-ChildItem -LiteralPath $storeParent -ErrorAction SilentlyContinue | Where-Object {
|
||||
$_.Name -like "$storeLeaf.*.tmp"
|
||||
} | ForEach-Object {
|
||||
Remove-Item -LiteralPath $_.FullName -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Item -LiteralPath $lockPath -Force -ErrorAction SilentlyContinue
|
||||
|
||||
$null = Start-MuninnServeProcess -ArgumentList $arguments
|
||||
|
||||
Start-Sleep -Seconds 2
|
||||
$processCheck = Get-StarfireMuninnServeProcess
|
||||
if ($null -eq $processCheck) {
|
||||
$serveError = if (Test-Path -LiteralPath $serveErrLog) {
|
||||
Get-Content -LiteralPath $serveErrLog -Raw
|
||||
} else {
|
||||
""
|
||||
}
|
||||
if ($serveError -like "*failed to decode MessagePack*") {
|
||||
Reset-CorruptMuninnStore
|
||||
$null = Start-MuninnServeProcess -ArgumentList $arguments
|
||||
Start-Sleep -Seconds 2
|
||||
$processCheck = Get-StarfireMuninnServeProcess
|
||||
}
|
||||
}
|
||||
if ($null -eq $processCheck) {
|
||||
throw "Starfire Muninn serve process is not running after restart"
|
||||
}
|
||||
foreach ($pattern in @(
|
||||
"--idunn-rudp-health",
|
||||
$IdunnRudpHealth,
|
||||
"--idunn-daemon",
|
||||
$IdunnDaemon,
|
||||
"--idunn-health-contract",
|
||||
$IdunnHealthContract
|
||||
)) {
|
||||
if ($processCheck.CommandLine -notlike "*$pattern*") {
|
||||
throw "Starfire Muninn serve command line is missing ${pattern}: $($processCheck.CommandLine)"
|
||||
}
|
||||
}
|
||||
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "health-starfire-muninn.ps1") `
|
||||
-MuninnExe $MuninnExe `
|
||||
-StorePath $StorePath
|
||||
|
|
|
|||
Loading…
Reference in a new issue