aien-sovereign-core
Autonomous sovereign intelligence engine and runtime core for NVIDIA DGX Spark
Brought by drakestapleton
aien-sovereign-core / crates / spark-supervisor / src / config.rs
| 1 | use serde::Deserialize; |
| 2 | use std::collections::HashMap; |
| 3 | use std::path::Path; |
| 4 | |
| 5 | #[derive(Debug, Clone, Deserialize)] |
| 6 | pub struct ServiceConfig { |
| 7 | pub command: String, |
| 8 | #[serde(default)] |
| 9 | pub args: Vec<String>, |
| 10 | #[serde(default)] |
| 11 | pub env: HashMap<String, String>, |
| 12 | #[serde(default = "default_restart")] |
| 13 | pub restart: String, |
| 14 | pub health_url: Option<String>, |
| 15 | } |
| 16 | |
| 17 | fn default_restart() -> String { |
| 18 | "always".to_string() |
| 19 | } |
| 20 | |
| 21 | #[derive(Debug, Clone, Deserialize)] |
| 22 | pub struct SupervisorConfig { |
| 23 | #[serde(default)] |
| 24 | pub services: HashMap<String, ServiceConfig>, |
| 25 | } |
| 26 | |
| 27 | impl SupervisorConfig { |
| 28 | pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn std::error::Error>> { |
| 29 | let content = std::fs::read_to_string(path)?; |
| 30 | let cfg: SupervisorConfig = toml::from_str(&content)?; |
| 31 | Ok(cfg) |
| 32 | } |
| 33 | } |