#[macro_use]
extern crate wei_log;
pub async fn start() -> Result<(), Box<dyn std::error::Error>> {
loop {
if wei_env::status() == "0" {
return Ok(());
}
let content = std::fs::read_to_string("./daemon.dat")?;
let map: serde_yaml::Value = serde_yaml::from_str(&content)?;
if let serde_yaml::Value::Mapping(m) = map.clone() {
for (k, _) in m {
let data = k.clone();
let name = data.as_str().expect("process is not string");
if !wei_run::is_process_running(name.clone()) {
info!("{} is not running", name);
wei_run::run_async(name, vec![])?;
}
}
}
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
}
}