Repository navigation
Expand file tree
/
Copy pathdev
More file actions
executable file
·57 lines (55 loc) · 1.69 KB
/
Copy pathdev
File metadata and controls
executable file
·57 lines (55 loc) · 1.69 KB
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
#!/bin/sh
set -eu
COMPOSE="compose.dev.yaml"
case "${1:-}" in
start)
shift
mkdir -p ops/hub-data/dev/events
docker compose -f "$COMPOSE" up -d --build --remove-orphans "$@"
wait_hub=1
if [ "$#" -gt 0 ]; then
wait_hub=0
for svc in "$@"; do
if [ "$svc" = "hub" ]; then wait_hub=1; fi
done
fi
if [ "$wait_hub" -eq 1 ]; then
echo "==> waiting for hub health (a cold start compiles first)"
i=0
until docker compose -f "$COMPOSE" exec -T hub curl -fsS http://localhost:9500/health >/dev/null 2>&1; do
if [ "$i" -ge 300 ]; then
echo "==> hub did not become healthy; recent logs follow"
docker compose -f "$COMPOSE" logs --tail=100 hub
exit 1
fi
i=$((i + 1))
sleep 2
done
if docker compose -f "$COMPOSE" logs hub 2>/dev/null | grep -q "migration ran"; then
docker compose -f "$COMPOSE" logs hub 2>/dev/null | grep "migration ran"
else
echo "==> hub schema already current"
fi
echo "==> hub database: $PWD/ops/hub-data/dev/hub.db"
echo "==> relay analytics database: $PWD/ops/hub-data/dev/events/events.db"
fi
;;
logs)
shift
docker compose -f "$COMPOSE" logs -f "$@"
;;
stop)
shift
if [ "$#" -gt 0 ]; then
docker compose -f "$COMPOSE" stop "$@"
else
docker compose -f "$COMPOSE" down
fi
;;
clean)
docker compose -f "$COMPOSE" down -v --remove-orphans
rm -rf "ops/hub-data/dev"
echo "==> purged containers, hub.db, cargo caches, and node_modules"
;;
*) echo "Usage: ./dev {start|logs|stop|clean} [service...] (services: web relay hub events-ingester grafana)"; exit 1 ;;
esac