2024-01-31 09:40:42 +00:00
|
|
|
use anyhow::{anyhow, Result};
|
2024-02-01 10:36:54 +00:00
|
|
|
use env_logger::Env;
|
2024-02-06 09:07:18 +00:00
|
|
|
use hyphactr::init::ContainerInit;
|
2024-01-31 09:40:42 +00:00
|
|
|
use std::env;
|
2024-01-17 16:18:12 +00:00
|
|
|
|
2024-02-05 12:45:45 +00:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<()> {
|
2024-01-31 04:22:48 +00:00
|
|
|
env::set_var("RUST_BACKTRACE", "1");
|
2024-02-01 12:20:13 +00:00
|
|
|
env_logger::Builder::from_env(Env::default().default_filter_or("warn")).init();
|
2024-01-31 09:40:42 +00:00
|
|
|
if env::var("HYPHA_UNSAFE_ALWAYS_ALLOW_INIT").unwrap_or("0".to_string()) != "1" {
|
|
|
|
let pid = std::process::id();
|
|
|
|
if pid > 3 {
|
|
|
|
return Err(anyhow!(
|
|
|
|
"not running because the pid of {} indicates this is probably not \
|
|
|
|
the right context for the init daemon. \
|
|
|
|
run with HYPHA_UNSAFE_ALWAYS_ALLOW_INIT=1 to bypass this check",
|
|
|
|
pid
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
2024-01-22 10:15:53 +00:00
|
|
|
let mut container = ContainerInit::new();
|
2024-02-05 12:45:45 +00:00
|
|
|
container.init().await?;
|
2024-01-17 16:18:12 +00:00
|
|
|
Ok(())
|
|
|
|
}
|