diff options
| author | Serguey Parkhomovsky <xindigo@gmail.com> | 2026-03-21 11:34:04 -0700 |
|---|---|---|
| committer | Serguey Parkhomovsky <xindigo@gmail.com> | 2026-03-21 11:34:04 -0700 |
| commit | f88f3214293a9dda29de209c457664a9886eacd8 (patch) | |
| tree | a1a53e837109736d5e68693a66723b360465b9f2 | |
| parent | e755cc4b45356b0484eb9254b4a0647cdca1591e (diff) | |
Move more panics to tracing
| -rw-r--r-- | src/main.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 5337fc3..246cd47 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use reqwest::Client; use rumqttc::{AsyncClient, Event, MqttOptions, Packet, QoS, Transport}; use std::collections::HashMap; use std::fs; +use std::process; use std::sync::Arc; use std::time::Duration; use tokio::sync::Mutex; @@ -30,8 +31,10 @@ async fn main() { tracing_subscriber::fmt::init(); let args = Args::parse(); - let content = fs::read_to_string(&args.config) - .unwrap_or_else(|e| panic!("Failed to read '{}': {}", args.config, e)); + let content = fs::read_to_string(&args.config).unwrap_or_else(|e| { + tracing::error!(path = %args.config, error = %e, "Failed to read config file"); + process::exit(1); + }); let config = Config::load(&content); let state: StateMap = Arc::new(Mutex::new(HashMap::new())); let mut tasks = JoinSet::new(); @@ -87,8 +90,11 @@ async fn main() { let listener = tokio::net::TcpListener::bind(&args.bind) .await - .unwrap_or_else(|e| panic!("Failed to bind to '{}': {}", args.bind, e)); - println!("Listening on {}", args.bind); + .unwrap_or_else(|e| { + tracing::error!(addr = %args.bind, error = %e, "Failed to bind to address"); + process::exit(1); + }); + tracing::info!(addr = %args.bind, "Listening"); axum::serve(listener, app).await.unwrap(); } |
