#!/bin/bash
# JetStream Health Check Script
set -e
NATS_URL="${NATS_URL:-nats://dagi-nats-node1:4222}"

echo "=== JETSTREAM STATUS ==="
echo ""

echo "1. Streams:"
docker run --rm --network dagi-network natsio/nats-box:latest nats -s "$NATS_URL" stream ls 2>/dev/null || {
    echo "   ❌ Failed to list streams"
    exit 1
}

echo ""
echo "2. Consumer Lag (ARTIFACT_JOBS):"
docker run --rm --network dagi-network natsio/nats-box:latest nats -s "$NATS_URL" consumer info ARTIFACT_JOBS render_pdf_worker 2>/dev/null | grep -E "Unprocessed|Ack Pending|Redelivered" || echo "   No consumer"

echo ""
echo "=== CHECK COMPLETE ==="
