#!/usr/bin/env bash
# Start (or restart) the QuitSure Assistant locally on http://localhost:8082/
cd "$(dirname "$0")/.." || exit 1
pkill -f "uvicorn app:app" 2>/dev/null
sleep 1
( nohup python3 -m uvicorn app:app --port 8082 --log-level warning </dev/null >/tmp/qs_support_ai.log 2>&1 & )
sleep 4
if curl -s localhost:8082/health >/dev/null; then
  echo "✅ QuitSure Assistant is live → http://localhost:8082/"
  echo "   logs: /tmp/qs_support_ai.log   |   stop: pkill -f 'uvicorn app:app'"
else
  echo "❌ failed to start — check /tmp/qs_support_ai.log"
fi
