File size: 2,768 Bytes
0122e2f
 
 
 
 
 
 
 
 
30ea1a1
0122e2f
 
 
 
 
 
 
 
 
 
b00cd33
0122e2f
 
 
 
 
 
 
 
 
 
 
b00cd33
0122e2f
b00cd33
 
30ea1a1
0122e2f
 
 
 
 
 
b00cd33
 
 
 
0122e2f
 
b00cd33
0122e2f
 
b00cd33
0122e2f
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -euo pipefail

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "  Redpanda β†’ HF Spaces"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

# ── 1. Start Redpanda ─────────────────────────────────────────────────────────
echo "[1/4] Starting Redpanda..."
/usr/bin/redpanda --redpanda-cfg /etc/redpanda/redpanda.yaml --smp 1 --memory 512M --reserve-memory 0M &

REDPANDA_PID=$!

# ── 2. Wait for broker ready ──────────────────────────────────────────────────
echo "[2/4] Waiting for Redpanda..."
ATTEMPTS=0
until curl -sf http://127.0.0.1:9644/v1/status/ready > /dev/null 2>&1; do
    ATTEMPTS=$((ATTEMPTS+1))
    if [ $ATTEMPTS -gt 60 ]; then
        echo "ERROR: Redpanda failed to start after 120s"
        kill $REDPANDA_PID 2>/dev/null || true
        exit 1
    fi
    echo "  ... waiting (${ATTEMPTS}/60)"
    sleep 2
done
echo "  βœ“ Redpanda ready"

# ── 3. Create topics ──────────────────────────────────────────────────────────
echo "[3/4] Initializing topics..."
/init-topics.sh

# ── 4. Start nginx on :7860 ───────────────────────────────────────────────────
echo "[4/4] Starting nginx on :7860..."
# Debian nginx binary lives at /usr/sbin/nginx
# pid to /tmp β€” writable by uid 1000
/usr/sbin/nginx -g "daemon off;" &
NGINX_PID=$!

echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "  βœ… All services up on port 7860"
echo ""
echo "  GET  /health       β†’ broker ready check"
echo "  *    /kafka/...    β†’ HTTP REST proxy (pandaproxy)"
echo "  *    /admin/...    β†’ admin API"
echo "  *    /schema/...   β†’ schema registry"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

# ── Graceful shutdown ─────────────────────────────────────────────────────────
cleanup() {
    echo "Shutting down..."
    kill $NGINX_PID    2>/dev/null || true
    kill $REDPANDA_PID 2>/dev/null || true
    exit 0
}
trap cleanup SIGTERM SIGINT

wait $REDPANDA_PID