Skip to main content

max / makenotwork

979 B · 29 lines History Blame Raw
1 use anyhow::{Context, Result};
2 use serde::Deserialize;
3 use std::path::PathBuf;
4
5 #[derive(Debug, Clone, Deserialize)]
6 pub struct Config {
7 pub listen: String,
8 pub db_path: PathBuf,
9 pub topology_path: PathBuf,
10 /// MM-local checkout scratch dir (per-sha worktrees live here).
11 pub workdir: PathBuf,
12 /// MM-local releases dir (`releases/<version>/` and `current` live here).
13 pub release_root: PathBuf,
14 /// Scratch postgres DB url used by `migration_dry_run`. Sando drops and
15 /// recreates the schema on every run, so do not point this at anything
16 /// you care about.
17 #[serde(default)]
18 pub scratch_db_url: Option<String>,
19 }
20
21 impl Config {
22 pub fn load() -> Result<Self> {
23 let path = std::env::var("SANDO_CONFIG").unwrap_or_else(|_| "sando-daemon.toml".into());
24 let raw = std::fs::read_to_string(&path)
25 .with_context(|| format!("reading daemon config at {path}"))?;
26 Ok(toml::from_str(&raw)?)
27 }
28 }
29