-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-stack.sh
More file actions
executable file
·95 lines (82 loc) · 3.34 KB
/
Copy pathstart-stack.sh
File metadata and controls
executable file
·95 lines (82 loc) · 3.34 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
# Dynamic stack launcher invoked by `make start`.
#
# Two responsibilities:
#
# 1. Generate `Procfile.dev.generated` based on which Python extras
# are installed in the current venv. Bare bootstrap → six core
# processes. With cfgrib (`make extras-grib`) → also materialise,
# verify, and the lagged-ensemble nowcaster, so the radar replay
# and Brier/CRPS calibration light up out of the box.
#
# 2. Background-trigger `scripts/seed-historical.sh` so the dashboard
# backfills a few hours of historical data while honcho boots,
# instead of staring at empty panels for the first ingest cycle.
# The seed script is idempotent — it short-circuits when the
# catalog is already populated.
#
# Static `Procfile.dev` stays as the manual reference (commented-out
# optional lines, comments explaining what to uncomment when). The
# generated file is gitignored.
set -euo pipefail
# Run from the repo root regardless of where the user invoked us, so
# the relative paths below (Procfile.dev.generated, scripts/…, .seed.log)
# all resolve identically whether `make start` triggered us or someone
# `./scripts/start-stack.sh`'d directly from the scripts/ dir.
HERE="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$HERE/.." && pwd)"
cd "$REPO_ROOT"
UV="${UV:-uv}"
PROCFILE_GENERATED="Procfile.dev.generated"
cfgrib_available() {
$UV run --quiet python -c \
"from aeroza.ingest.mrms_decode import ensure_cfgrib_available; ensure_cfgrib_available()" \
>/dev/null 2>&1
}
write_procfile() {
cat > "$PROCFILE_GENERATED" <<'EOF'
# Auto-generated by scripts/start-stack.sh — do not commit.
# Edit Procfile.dev (the static reference) instead, and re-run
# `make start` to regenerate this file.
api: uv run uvicorn aeroza.main:app --reload --host 0.0.0.0 --port 8000
web: npm --prefix web run dev
alerts: uv run aeroza-ingest-alerts
mrms: uv run aeroza-ingest-mrms
metar: uv run aeroza-ingest-metar
webhooks: uv run aeroza-dispatch-webhooks
EOF
if cfgrib_available; then
cat >> "$PROCFILE_GENERATED" <<'EOF'
# cfgrib detected — running the GRIB → Zarr → nowcast → verify chain.
materialise: uv run aeroza-materialise-mrms
verify: uv run aeroza-verify-nowcasts
nowcast: uv run aeroza-nowcast-mrms --algorithm lagged-ensemble
EOF
return 0
fi
return 1
}
main() {
if write_procfile; then
printf "\033[32mDetected cfgrib — running materialise + nowcast (lagged-ensemble) + verify alongside the core stack.\033[0m\n"
else
printf "\033[33mcfgrib not installed — radar replay and calibration will stay empty.\033[0m\n"
printf " Install with: \033[36mmake extras-grib\033[0m, then re-run \033[36mmake start\033[0m.\n"
fi
# Background-trigger the historical-data seeder. It waits for the
# API to come up, probes /v1/stats for an empty catalog, and only
# then runs — so re-running `make start` is safe.
(
# Detach into its own process group so Ctrl+C on honcho doesn't
# take it down mid-ingest.
set -m
AEROZA_API_URL="${AEROZA_API_URL:-http://localhost:8000}" \
./scripts/seed-historical.sh \
>> .seed.log 2>&1 \
&
)
printf "\nStarting Aeroza dev stack — Ctrl+C stops everything.\n"
printf " Seed log: \033[36mtail -f .seed.log\033[0m\n\n"
exec $UV run honcho -f "$PROCFILE_GENERATED" start
}
main "$@"