#!/usr/bin/env bash
set -u

cd "$HOME/AI-Coach/health-watcher-prod"

mkdir -p logs

echo "$(date -Is) watcher loop started" >> logs/watcher_loop.log

while true; do
  echo "$(date -Is) watcher cycle start" >> logs/watcher_loop.log
  python3 scripts/watcher_event_queue.py >> logs/watcher_loop.log 2>&1
  rc=$?
  echo "$(date -Is) watcher cycle end rc=$rc" >> logs/watcher_loop.log
  sleep 3
done
