Add live run scripts and watchdog cron support for autonomous uptime

This commit is contained in:
2026-02-26 09:12:46 -08:00
parent ddc42254fa
commit 94aba00967
2 changed files with 42 additions and 0 deletions

13
scripts/start_live.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="/home/drjones/.openclaw/workspace/alpaca-llm-bot-v1"
LOGDIR="/home/drjones/.openclaw/workspace/logs"
mkdir -p "$LOGDIR"
cd "$ROOT"
if [[ -f "$LOGDIR/alpaca-bot.pid" ]] && kill -0 "$(cat $LOGDIR/alpaca-bot.pid)" 2>/dev/null; then
echo "already_running"
exit 0
fi
nohup python3 -m uvicorn app:app --host 0.0.0.0 --port 8089 > "$LOGDIR/alpaca-bot.log" 2>&1 &
echo $! > "$LOGDIR/alpaca-bot.pid"
echo "started $(cat $LOGDIR/alpaca-bot.pid)"

29
scripts/watchdog.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="/home/drjones/.openclaw/workspace/alpaca-llm-bot-v1"
LOGDIR="/home/drjones/.openclaw/workspace/logs"
mkdir -p "$LOGDIR"
PIDFILE="$LOGDIR/alpaca-bot.pid"
HEALTH_URL="http://127.0.0.1:8089/health"
need_start=0
if [[ ! -f "$PIDFILE" ]]; then
need_start=1
else
pid=$(cat "$PIDFILE" || true)
if [[ -z "$pid" ]] || ! kill -0 "$pid" 2>/dev/null; then
need_start=1
fi
fi
if [[ $need_start -eq 0 ]]; then
if ! curl -fsS -m 3 "$HEALTH_URL" >/dev/null; then
pid=$(cat "$PIDFILE" || true)
[[ -n "$pid" ]] && kill "$pid" 2>/dev/null || true
need_start=1
fi
fi
if [[ $need_start -eq 1 ]]; then
"$ROOT/scripts/start_live.sh" >> "$LOGDIR/alpaca-watchdog.log" 2>&1
fi