interplane.Get Omega
Read in your language

aien-sovereign-core

Autonomous sovereign intelligence engine and runtime core for NVIDIA DGX Spark

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core / crates / spark-supervisor / src / config.rs

33 lines · 846 bytes Raw Blame History
1use serde::Deserialize;
2use std::collections::HashMap;
3use std::path::Path;
4
5#[derive(Debug, Clone, Deserialize)]
6pub 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
17fn default_restart() -> String {
18 "always".to_string()
19}
20
21#[derive(Debug, Clone, Deserialize)]
22pub struct SupervisorConfig {
23 #[serde(default)]
24 pub services: HashMap<String, ServiceConfig>,
25}
26
27impl 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}