Files
unshell/unshell-server/src/server/mod.rs
T

35 lines
901 B
Rust
Raw Normal View History

2025-12-17 10:38:37 -07:00
use std::{error::Error, path::PathBuf};
mod database;
mod manager;
#[derive(Clone)]
pub struct Server {
2025-12-17 10:38:37 -07:00
pub component_configs: Vec<crate::config::ComponentState>,
2025-12-17 10:20:50 -07:00
// pub manager: Arc<Mutex<Manager>>,
pub db: sled::Db,
}
impl Server {
2025-12-17 10:38:37 -07:00
pub fn new(config_paths: Vec<PathBuf>, database: String) -> Result<Self, Box<dyn Error>> {
let mut component_configs: Vec<crate::config::ComponentState> = Vec::new();
for config in &config_paths {
component_configs.extend(crate::config::load_config(config)?);
}
2025-12-17 10:38:37 -07:00
Ok(Self {
component_configs,
// manager: Manager::start(&SERVER_CONFIG, Vec::new()),
db: sled::open(database)?,
})
}
}
impl Drop for Server {
fn drop(&mut self) {
self.db.flush().expect("Failed to flush database on drop");
2025-12-17 10:20:50 -07:00
// Manager::join(self.manager.clone());
}
}