diff --git a/src/apps.rs b/src/apps.rs index d312e71..e584dc2 100644 --- a/src/apps.rs +++ b/src/apps.rs @@ -12,13 +12,15 @@ use crate::app::App; use crate::proc::Proc; use crate::result::Result; +/// List of apps to start and monitor #[derive(Debug, Deserialize)] pub struct Apps { + /// List of apps to start and monitor pub app: Vec, } impl Apps { - /// load apps from toml file + /// Load apps from toml file pub fn load(p: PathBuf) -> Result { let path: String = p.display().to_string(); @@ -46,6 +48,7 @@ impl Apps { } } + /// Get a list of the apps as a `Vec` pub fn apps(&self) -> Vec { self.app.clone() } diff --git a/src/main.rs b/src/main.rs index 4a8b591..d254b51 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,16 +17,20 @@ use result::Result; use run::run; fn main() { + // config comes from command line arguments let config = Config::from_args(); + // logger must be initialized because we use it a bunch if let Err(e) = logger::setup(config.log_file, config.log_level) { println!("FATAL: Error initializing logger: {:?}", e); std::process::exit(1); } + // apps_file is where the applications to start are configured let mut apps_file = config.config_directory.clone(); apps_file.push("apps.toml"); + // start the apps match startup(apps_file) { Ok(p) => { info!("shutting down"); @@ -41,9 +45,15 @@ fn main() { }; } +/// Load the apps file and start the apps fn startup(apps_file: PathBuf) -> Result> { let apps = Apps::load(apps_file)?; + + // start all the apps let (procs, holds, poll) = apps.start(); + + // wait for events let procs = run(procs, holds, poll)?; + Ok(procs) }