ADR-014: Runtime Configuration and Operations
Metadata:
- ID: ADR-014
- Status: Accepted
- Date: 2025-03-21
- Tags: [config, ops, deployment]
- Decision Type: architecture_pattern
- Related: [ADR-007, ADR-008, ADR-012, ADR-013, ADR-016]
- Supersedes: []
- Superseded By: []
Context
Problem: Running cartopolis_simulator on a host (ADR-007) requires listen address, database path, tile URL template, texture dir, tick rate, and AOI radius (ADR-012) without recompiling.
Requirements:
- Sensible defaults for local dev
- Overrides via env vars and/or config file
- Documented for minimal VPS deployment
Decision
Layered config: defaults in code → optional cartopolis.toml → CARTO_* env vars → CLI flags (clap), each layer overriding the previous.
Implementation (cartopolis_simulator/src/config.rs, cli.rs):
figmentwithSerialized::defaults+Toml+Env::prefixed("CARTO_")providers on aserde-derivedSimConfig.apply_clilayersclapflag overrides on top.- Logging:
tracing+tracing-subscriberwithEnvFilter.
Config keys (all with in-code defaults):
listen(127.0.0.1:4747) — bind host:port, ADR-008database_path(data/world.db) — ADR-013tick_hz(20.0),aoi_radius(500.0) — ADR-012osm_tile_url_template(https://tile.openstreetmap.org/{z}/{x}/{y}.png) — client tile handoff, ADR-004texture_dir(data/textures) — directory of*.pngtextures served to clients
cartopolis.toml is loaded only if present; env keys are CARTO_<field> (e.g. CARTO_listen).
Rationale
Primary Reasoning:
- 12-factor style env overrides are standard for containers.
- File config matches operator expectations for a dedicated server.
- Separation: Keeps secrets out of source control.
Alternatives Considered:
| Alternative | Pros | Cons | Rejected Because |
|---|---|---|---|
| Env only | Simple | Tedious for many keys | File + env is nicer |
| CLI only | Explicit | Poor for services | Not sufficient alone |
| Dynamic remote config | Fancy | Ops burden | Future |
Consequences
Positive:
- Repeatable deploys; easy to document “minimum viable server”
- Ties ADR-007–013 together operationally
Negative:
- Config schema must be versioned with protocol (mitigation: document breaking changes in CHANGELOG)