Environment variables for the relay

Configure upstream URLs, Redis DSN, TTL seconds, and log levels without editing Python source on the server.

Close-up of white Cat-5e Ethernet cables with RJ45 connectors
Probe JSON usually leaves the LAN over Ethernet or a nearby relay, not the public internet directly. Photo: DiscDepotDundee.co.uk. CC BY-SA 4.0

Relays read configuration from the environment at startup: where the Arduino lives, how long to cache JSON, which Redis DB index to use, and how verbose logging should be. Hard-coding LAN IPs in source leads to git leaks and rebuilds for trivial changes: environment variables align with Docker deployment and production hygiene.

Env file keys flowing into relay process configuration blocks
Environment variables supply upstream URL, Redis DSN, TTL, and log level at container start.

Common variables

        UPSTREAM_URL=http://192.168.1.50/
REDIS_URL=redis://redis:6379/0
CACHE_TTL_SECONDS=60
LOG_LEVEL=info
      

Secrets handling

Optional API keys for public relay auth belong in env, not committed files. Mirror patterns from Cloudflare secrets on the Astro side. Never store database credentials in the relay: it only needs to serve JSON, or push readings through the device ingest API.

Validation on boot

Fail fast when UPSTREAM_URL is missing; log resolved values once at INFO. Pair with health checks so orchestrators restart unhealthy containers instead of serving blank JSON.