This commit is contained in:
2024-01-31 17:06:39 +01:00
parent f40922030c
commit cff7dddf4e
3 changed files with 70 additions and 5 deletions

View File

@ -3,10 +3,10 @@ mod routes;
use clap::Parser;
use dotenv::dotenv;
use eyre::Context;
use health::HealthState;
use rocket::fs::FileServer;
use rocket_dyn_templates::Template;
use std::io;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
@ -20,14 +20,16 @@ struct Opt {
}
#[rocket::main]
async fn main() -> io::Result<()> {
async fn main() -> eyre::Result<()> {
dotenv().ok();
let opt = Opt::parse();
color_eyre::install()?;
let config = fs::read_to_string(&opt.config)
.await
.expect("failed to read config file");
let config = ron::from_str(&config).expect("failed to parse config file");
.wrap_err_with(|| format!("failed to read config file: {:?}", opt.config))?;
let config = ron::from_str(&config)
.wrap_err_with(|| format!("failed to parse config file: {:?}", opt.config))?;
let state = Arc::new(HealthState::new(config));
let rocket = rocket::build()
@ -38,7 +40,7 @@ async fn main() -> io::Result<()> {
start_poller(state);
rocket.launch().await.expect("rocket failed to launch");
rocket.launch().await.wrap_err("rocket failed to launch")?;
Ok(())
}