dotfiles/agent/src/main.rs

38 lines
921 B
Rust
Raw Normal View History

2024-01-29 10:44:00 +00:00
use health::init_health_subsystem;
use messaging::Client;
use services::init_services;
2024-01-24 23:18:30 +00:00
use tracing::Level;
2024-01-25 15:16:27 +00:00
mod health;
2024-01-26 16:22:09 +00:00
mod messaging;
2024-01-27 21:01:59 +00:00
mod services;
2024-01-25 15:16:27 +00:00
2024-01-24 23:18:30 +00:00
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let subscriber = tracing_subscriber::fmt()
.with_max_level(Level::TRACE)
.finish();
tracing::subscriber::set_global_default(subscriber)
.expect("to set a tracing global subscriber");
2024-01-26 16:22:09 +00:00
run().await.map_err(|err| {
tracing::error!(cause = %err, "could not start agent");
err
})
}
2024-01-25 15:16:27 +00:00
2024-01-26 16:22:09 +00:00
async fn run() -> anyhow::Result<()> {
2024-01-29 10:44:00 +00:00
let client = Client::connect("demo_agent").await?;
let _health_monitor = init_health_subsystem(client.clone()).await;
2024-01-26 16:22:09 +00:00
tracing::info!("initialized health system");
2024-01-29 10:44:00 +00:00
init_services(client).await;
tracing::info!("initialized services");
2024-01-26 16:22:09 +00:00
tracing::info!("agent is ready");
2024-01-25 15:16:27 +00:00
tokio::signal::ctrl_c().await?;
2024-01-24 23:18:30 +00:00
Ok(())
}