#!/usr/bin/env bash # Boot the full leaflet_svelte ↔ stratoflights ↔ predictor test stack. # # Processes started (background): # - fake_tawhiri (Python http.server, :8001) — synthesizes prediction responses # - stratoflights Django (runserver, :8000) — API backend, talks to fake_tawhiri # - leaflet_svelte Vite dev server (:5173) — proxies /api to Django # # After this, run tests with: # npm run test:e2e # # Stop everything with: # scripts/stop-stack.sh # # Requirements (once): # - Python deps: pip install --user --break-system-packages Django djangorestframework \ # djangorestframework-simplejwt drf-spectacular requests django-cors-headers \ # Pillow python-dotenv channels daphne # - `demo` user in Django with password `demo`: # DJANGO_ENV=production python3 manage.py createsuperuser (--noinput with env) set -euo pipefail FRONTEND_DIR=/home/anton/leaflet_svelte BACKEND_DIR=/home/anton/stratoflights PID_DIR=/tmp/lsv-stack mkdir -p "$PID_DIR" # --- fake_tawhiri ---------------------------------------------------------------- if ! ss -tlnp 2>/dev/null | grep -q ':8001'; then echo "starting fake_tawhiri on :8001" python3 "$FRONTEND_DIR/tests/e2e/fake_tawhiri.py" > /tmp/fake-tawhiri.log 2>&1 & echo $! > "$PID_DIR/fake-tawhiri.pid" fi # --- stratoflights Django -------------------------------------------------------- if ! ss -tlnp 2>/dev/null | grep -q ':8000'; then echo "starting stratoflights on :8000" cd "$BACKEND_DIR" DJANGO_ENV=production \ DEBUG=True \ ALLOWED_HOSTS=localhost,127.0.0.1 \ CSRF_TRUSTED_ORIGINS="http://localhost:5173,http://localhost:8000,http://127.0.0.1:5173,http://127.0.0.1:8000" \ TAWHIRI_BASE_URL=http://127.0.0.1:8001/api/v2/ \ python3 manage.py runserver 0.0.0.0:8000 > /tmp/django.log 2>&1 & echo $! > "$PID_DIR/django.pid" sleep 3 fi # --- leaflet_svelte -------------------------------------------------------------- if ! ss -tlnp 2>/dev/null | grep -q ':5173'; then echo "starting Vite on :5173" cd "$FRONTEND_DIR" VITE_USE_MOCK_API=false \ VITE_API_BASE_URL=/api \ VITE_API_PROXY_TARGET=http://localhost:8000 \ npm run dev -- --port 5173 --strictPort > /tmp/vite-dev.log 2>&1 & echo $! > "$PID_DIR/vite.pid" sleep 3 fi echo "--- stack ready ---" echo " fake_tawhiri: http://127.0.0.1:8001/api/v2/" echo " stratoflights: http://localhost:8000/api/" echo " leaflet_svelte: http://localhost:5173/" echo echo "logs: /tmp/fake-tawhiri.log, /tmp/django.log, /tmp/vite-dev.log" echo "run e2e: (cd $FRONTEND_DIR && npm run test:e2e)" echo "stop: $FRONTEND_DIR/scripts/stop-stack.sh"