feat(reliability): risky-op preflight snapshots + detached rollback watchdog
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
# Usage: mk8-watchdog.sh <profile> <interval> <fail_after> <healthy_after>
|
||||
PROFILE="$1"; IV="${2:-5}"; FA="${3:-6}"; HA="${4:-6}"
|
||||
DIR="/root/payloads/user/remote_access/pager-webui"
|
||||
[ -f "$DIR/server.py" ] || DIR="/mmc/mk8/releases/current"
|
||||
fails=0; oks=0; tripped=0
|
||||
probe() {
|
||||
curl -fsS -m 3 http://127.0.0.1:8080/ >/dev/null 2>&1 &&
|
||||
{ ip link show wlan0mon >/dev/null 2>&1 ||
|
||||
ip link show wlan1mon >/dev/null 2>&1; }
|
||||
}
|
||||
while true; do
|
||||
if probe; then
|
||||
fails=0
|
||||
if [ "$tripped" = "1" ]; then
|
||||
oks=$((oks + 1))
|
||||
if [ "$oks" -ge "$HA" ]; then
|
||||
/usr/bin/python3 "$DIR/server.py" --promote-snapshot "$PROFILE" >/dev/null 2>&1
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
else
|
||||
fails=$((fails + 1)); oks=0
|
||||
if [ "$tripped" = "0" ] && [ "$fails" -ge "$FA" ]; then
|
||||
tripped=1
|
||||
/usr/bin/python3 "$DIR/server.py" --rollback-snapshot "$PROFILE" >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
sleep "$IV"
|
||||
done
|
||||
Reference in New Issue
Block a user