Route Nightwing Muninn lifecycle through Idunn
This commit is contained in:
parent
71c204f824
commit
01f9a992fd
5 changed files with 79 additions and 3 deletions
2
scripts/health-nightwing-muninn.cmd
Normal file
2
scripts/health-nightwing-muninn.cmd
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
@echo off
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\health-nightwing-muninn.ps1
|
||||
28
scripts/health-nightwing-muninn.ps1
Normal file
28
scripts/health-nightwing-muninn.ps1
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
param(
|
||||
[string] $SshTarget = "nightwing",
|
||||
[string] $MuninnExe = "/home/metacrat/.local/bin/muninn",
|
||||
[string] $StorePath = "/home/metacrat/.local/state/gamecult/muninn/muninn.telemetry.cc",
|
||||
[string] $PidPath = "/home/metacrat/.local/state/gamecult/muninn/muninn.pid"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$remoteScript = @"
|
||||
set -eu
|
||||
if [ ! -x '$MuninnExe' ]; then
|
||||
echo 'Muninn executable not found at $MuninnExe' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -f '$PidPath' ] && kill -0 "`$(cat '$PidPath')" 2>/dev/null; then
|
||||
:
|
||||
elif pgrep -f '[m]uninn serve .*--host nightwing' >/dev/null 2>&1; then
|
||||
:
|
||||
else
|
||||
echo 'Muninn serve process is not running on Nightwing' >&2
|
||||
exit 1
|
||||
fi
|
||||
'$MuninnExe' --health --store '$StorePath'
|
||||
"@
|
||||
|
||||
ssh.exe -o BatchMode=yes -o ConnectTimeout=5 $SshTarget $remoteScript
|
||||
exit $LASTEXITCODE
|
||||
2
scripts/restart-nightwing-muninn.cmd
Normal file
2
scripts/restart-nightwing-muninn.cmd
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
@echo off
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\restart-nightwing-muninn.ps1
|
||||
39
scripts/restart-nightwing-muninn.ps1
Normal file
39
scripts/restart-nightwing-muninn.ps1
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
param(
|
||||
[string] $SshTarget = "nightwing",
|
||||
[string] $MuninnExe = "/home/metacrat/.local/bin/muninn",
|
||||
[string] $StorePath = "/home/metacrat/.local/state/gamecult/muninn/muninn.telemetry.cc",
|
||||
[string] $LogRoot = "/home/metacrat/.local/state/gamecult/muninn",
|
||||
[int] $IntervalSeconds = 15
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$remoteScript = @"
|
||||
set -eu
|
||||
mkdir -p '$LogRoot'
|
||||
if [ ! -x '$MuninnExe' ]; then
|
||||
echo 'Muninn executable not found at $MuninnExe' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -f '$LogRoot/muninn.pid' ] && kill -0 "`$(cat '$LogRoot/muninn.pid')" 2>/dev/null; then
|
||||
kill "`$(cat '$LogRoot/muninn.pid')" 2>/dev/null || true
|
||||
sleep 1
|
||||
fi
|
||||
for pid in `$(pgrep -f '[m]uninn serve .*--host nightwing' 2>/dev/null || true); do
|
||||
kill "`$pid" 2>/dev/null || true
|
||||
done
|
||||
nohup '$MuninnExe' serve \
|
||||
--store '$StorePath' \
|
||||
--log-root '$LogRoot' \
|
||||
--host nightwing \
|
||||
--interval-seconds '$IntervalSeconds' \
|
||||
> '$LogRoot/muninn-serve.out.log' \
|
||||
2> '$LogRoot/muninn-serve.err.log' \
|
||||
< /dev/null &
|
||||
echo `$! > '$LogRoot/muninn.pid'
|
||||
sleep 1
|
||||
kill -0 "`$(cat '$LogRoot/muninn.pid')" 2>/dev/null
|
||||
"@
|
||||
|
||||
ssh.exe -o BatchMode=yes -o ConnectTimeout=5 $SshTarget $remoteScript
|
||||
exit $LASTEXITCODE
|
||||
Loading…
Reference in a new issue