29 lines
965 B
Bash
Executable File
29 lines
965 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Cron-friendly script to trigger degelas data refreshes.
|
|
# Run from host; uses docker exec to hit the backend (no network/DNS needed).
|
|
# Usage: ./cron-refresh.sh [prices|metrics|all]
|
|
# prices - electricity prices + baseline predictions (full 21-day window)
|
|
# metrics - solar/weather metrics for all locations
|
|
# all - both (default)
|
|
|
|
set -e
|
|
CONTAINER="${DEGELAS_BACKEND_CONTAINER:-degelas-backend}"
|
|
BASE="http://localhost:8000"
|
|
|
|
case "${1:-all}" in
|
|
prices)
|
|
docker exec "$CONTAINER" curl -s -X POST "$BASE/prices/refresh" --max-time 300
|
|
;;
|
|
metrics)
|
|
docker exec "$CONTAINER" curl -s -X POST "$BASE/metrics/refresh-all-locations" --max-time 120
|
|
;;
|
|
all)
|
|
docker exec "$CONTAINER" curl -s -X POST "$BASE/prices/refresh" --max-time 300
|
|
docker exec "$CONTAINER" curl -s -X POST "$BASE/metrics/refresh-all-locations" --max-time 120
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [prices|metrics|all]" >&2
|
|
exit 1
|
|
;;
|
|
esac
|