#!/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