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
|
|
@ -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