#!/usr/bin/env bash set -euo pipefail ssh -o BatchMode=yes eventhub-ift bash -s <<'REMOTE' set -euo pipefail cd /opt/ai-router-stack set -a; source .env; set +a echo "== Services ==" docker stack services ai-router --format '{{.Name}} {{.Replicas}} {{.Image}}' | grep -E 'litellm|postgres|router' || true echo "== Health ==" curl -sS -o /tmp/llh.txt -w "liveliness:%{http_code}\n" --max-time 10 https://litellm.ift.calentiq.com/health/liveliness || true curl -sS -o /tmp/llr.txt -w "readiness:%{http_code}\n" --max-time 10 https://litellm.ift.calentiq.com/health/readiness || true head -c 300 /tmp/llh.txt; echo; head -c 500 /tmp/llr.txt; echo echo "== Recent litellm logs (errors) ==" docker service logs --tail 120 ai-router_litellm 2>&1 \ | grep -iE 'error|exception|fail|traceback|500|401|prisma|database|budget|key|warning' \ | tail -60 || true echo "== Last 40 lines raw ==" docker service logs --tail 40 ai-router_litellm 2>&1 | tail -40 echo "== Postgres quick ==" PG=$(docker ps -q -f name=ai-router_postgres | head -1) docker exec -e PGPASSWORD="$POSTGRES_PASSWORD" "$PG" \ psql -U "${POSTGRES_USER:-litellm}" -d "${POSTGRES_DB:-litellm}" -c \ "SELECT count(*) AS spend FROM \"LiteLLM_SpendLogs\"; SELECT count(*) AS users FROM \"LiteLLM_UserTable\"; SELECT count(*) AS tokens FROM \"LiteLLM_VerificationToken\";" echo "== UI/home probe ==" curl -sS -o /tmp/ui.txt -w "ui:%{http_code}\n" --max-time 15 https://litellm.ift.calentiq.com/ui/ || true curl -sS -o /tmp/models.txt -w "models:%{http_code}\n" --max-time 20 \ -H "Authorization: Bearer ${LITELLM_MASTER_KEY}" \ https://litellm.ift.calentiq.com/v1/models || true head -c 200 /tmp/models.txt; echo REMOTE