fix(uno-q): supervisor survives reboot + recover actually launches it #6
@@ -36,7 +36,9 @@ echo " forward :8080 · reverse :$SHIM_PORT"
|
|||||||
|
|
||||||
echo "==> [3/5] ensure on-board supervisor is running"
|
echo "==> [3/5] ensure on-board supervisor is running"
|
||||||
if a shell "test -x $SUPERVISOR" 2>/dev/null; then
|
if a shell "test -x $SUPERVISOR" 2>/dev/null; then
|
||||||
a shell "pgrep -f zeroclaw-supervisor >/dev/null 2>&1 \
|
# Bracket the pattern so the pgrep's own shell (whose args contain the
|
||||||
|
# supervisor path) doesn't self-match and skip the launch.
|
||||||
|
a shell "pgrep -f '[z]eroclaw-supervisor.sh' >/dev/null 2>&1 \
|
||||||
|| (setsid nohup $SUPERVISOR >/dev/null 2>&1 < /dev/null &)" >/dev/null 2>&1
|
|| (setsid nohup $SUPERVISOR >/dev/null 2>&1 < /dev/null &)" >/dev/null 2>&1
|
||||||
echo " supervisor ensured (restarts llama + daemon on death/wedge)"
|
echo " supervisor ensured (restarts llama + daemon on death/wedge)"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
# Boot persist: crontab -l | { cat; echo '@reboot /home/arduino/zeroclaw-supervisor.sh'; } | crontab -
|
# Boot persist: crontab -l | { cat; echo '@reboot /home/arduino/zeroclaw-supervisor.sh'; } | crontab -
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
|
# cron's @reboot env is minimal — guarantee the tools we shell out to are found.
|
||||||
|
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH:-}
|
||||||
|
|
||||||
HOME_DIR=/home/arduino
|
HOME_DIR=/home/arduino
|
||||||
LLAMA_DIR="$HOME_DIR/llama"
|
LLAMA_DIR="$HOME_DIR/llama"
|
||||||
MODEL="$HOME_DIR/models/qwen.gguf"
|
MODEL="$HOME_DIR/models/qwen.gguf"
|
||||||
@@ -30,10 +33,16 @@ log() { echo "[$(date '+%F %T')] $*" >> "$LOG"; }
|
|||||||
now() { date +%s; }
|
now() { date +%s; }
|
||||||
healthy() { curl -sf --max-time 4 "http://127.0.0.1:$1/health" >/dev/null 2>&1; }
|
healthy() { curl -sf --max-time 4 "http://127.0.0.1:$1/health" >/dev/null 2>&1; }
|
||||||
|
|
||||||
# single-instance guard (no flock dependency)
|
# single-instance guard (no flock dependency). Pid-reuse-safe: a stale lock
|
||||||
if [ -f "$LOCK" ] && kill -0 "$(cat "$LOCK" 2>/dev/null)" 2>/dev/null; then
|
# whose pid was recycled by an unrelated process (common right after a reboot)
|
||||||
log "supervisor already running (pid $(cat "$LOCK")) — exiting"
|
# must NOT block startup — so require the live pid to actually be a supervisor.
|
||||||
|
if [ -f "$LOCK" ]; then
|
||||||
|
OLDPID=$(cat "$LOCK" 2>/dev/null)
|
||||||
|
if [ -n "$OLDPID" ] && kill -0 "$OLDPID" 2>/dev/null \
|
||||||
|
&& grep -qa zeroclaw-supervisor "/proc/$OLDPID/cmdline" 2>/dev/null; then
|
||||||
|
log "supervisor already running (pid $OLDPID) — exiting"
|
||||||
exit 0
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo $$ > "$LOCK"
|
echo $$ > "$LOCK"
|
||||||
trap 'rm -f "$LOCK"' EXIT
|
trap 'rm -f "$LOCK"' EXIT
|
||||||
|
|||||||
Reference in New Issue
Block a user