#!/usr/bin/env bash
# 오류감시 기동 (systemd 없이 nohup). sudo 있으면 deploy 유닛 사용 권장.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
mkdir -p logs
pkill -f 'scripts/kis_error_watch_mm.py' 2>/dev/null || true
sleep 1
nohup "$ROOT/.venv/bin/python" -u "$ROOT/scripts/kis_error_watch_mm.py" \
  >> "$ROOT/logs/kis_error_watch_mm.log" 2>&1 &
echo "PID=$!"
echo "LOG=$ROOT/logs/kis_error_watch_mm.log"
echo "tail -f $ROOT/logs/kis_error_watch_mm.log"
