add and fix up comments

master
rascul 2 years ago
parent 4112b6d434
commit 70cc873c53

@ -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<App>,
}
impl Apps {
/// load apps from toml file
/// Load apps from toml file
pub fn load(p: PathBuf) -> Result<Self> {
let path: String = p.display().to_string();
@ -46,6 +48,7 @@ impl Apps {
}
}
/// Get a list of the apps as a `Vec<App>`
pub fn apps(&self) -> Vec<App> {
self.app.clone()
}

@ -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<Vec<Proc>> {
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)
}

Loading…
Cancel
Save