diff --git a/scripts/health-stonks.cmd b/scripts/health-stonks.cmd new file mode 100644 index 0000000..ecf43b5 --- /dev/null +++ b/scripts/health-stonks.cmd @@ -0,0 +1,2 @@ +@echo off +curl.exe -fsS http://127.0.0.1:8802/health >NUL diff --git a/scripts/restart-stonks.cmd b/scripts/restart-stonks.cmd new file mode 100644 index 0000000..980c069 --- /dev/null +++ b/scripts/restart-stonks.cmd @@ -0,0 +1,2 @@ +@echo off +powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\restart-stonks.ps1 diff --git a/scripts/restart-stonks.ps1 b/scripts/restart-stonks.ps1 new file mode 100644 index 0000000..c3f5f0e --- /dev/null +++ b/scripts/restart-stonks.ps1 @@ -0,0 +1,21 @@ +$ErrorActionPreference = "Stop" + +$stonksRoot = "E:\Projects\Stonks" +$stateDir = Join-Path $stonksRoot "scratch\stonks" +$pidPath = Join-Path $stateDir "stonks.pid" +$startScript = Join-Path $stonksRoot "scripts\start-stonks.ps1" + +if (Test-Path -LiteralPath $pidPath) { + $pidText = (Get-Content -LiteralPath $pidPath -Raw).Trim() + if ($pidText -match "^\d+$") { + $process = Get-Process -Id ([int] $pidText) -ErrorAction SilentlyContinue + if ($null -ne $process) { + Stop-Process -Id $process.Id -Force + Start-Sleep -Milliseconds 500 + } + } + Remove-Item -LiteralPath $pidPath -Force -ErrorAction SilentlyContinue +} + +& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $startScript +exit $LASTEXITCODE diff --git a/scripts/start-idunn-local.ps1 b/scripts/start-idunn-local.ps1 index 1678001..66b20c3 100644 --- a/scripts/start-idunn-local.ps1 +++ b/scripts/start-idunn-local.ps1 @@ -39,6 +39,13 @@ $watchdogs = @( Health = "$repoRoot\scripts\health-mimir-eve-dashboard.cmd" Restart = $null }, + [pscustomobject]@{ + Id = "stonks" + Name = "Stonks market pulse" + Verse = "starfire.local" + Health = "$repoRoot\scripts\health-stonks.cmd" + Restart = "$repoRoot\scripts\restart-stonks.cmd" + }, [pscustomobject]@{ Id = "nightwing-gjallar" Name = "Nightwing Gjallar framebuffer compositor" diff --git a/src/Idunn/README.md b/src/Idunn/README.md index 85362c3..c9c1379 100644 --- a/src/Idunn/README.md +++ b/src/Idunn/README.md @@ -73,9 +73,9 @@ Install the local Starfire boot watchdogs: .\scripts\install-idunn-startup.ps1 ``` -That task starts Idunn loops for Odin and the Nightwing display services at -user logon. The current Mimir dashboard is observed but not restarted until its -restart authority is named. +That task starts Idunn loops for Odin, Stonks, and the Nightwing display +services at user logon. The current Mimir dashboard is observed but not +restarted until its restart authority is named. To record a failed health check and request a restart without actuating: