use anyhow::{Context, Result}; use serde::Deserialize; use std::path::PathBuf; #[derive(Debug, Clone, Deserialize)] pub struct Config { pub listen: String, pub db_path: PathBuf, pub topology_path: PathBuf, /// MM-local checkout scratch dir (per-sha worktrees live here). pub workdir: PathBuf, /// MM-local releases dir (`releases//` and `current` live here). pub release_root: PathBuf, /// Scratch postgres DB url used by `migration_dry_run`. Sando drops and /// recreates the schema on every run, so do not point this at anything /// you care about. #[serde(default)] pub scratch_db_url: Option, } impl Config { pub fn load() -> Result { let path = std::env::var("SANDO_CONFIG").unwrap_or_else(|_| "sando-daemon.toml".into()); let raw = std::fs::read_to_string(&path) .with_context(|| format!("reading daemon config at {path}"))?; Ok(toml::from_str(&raw)?) } }