From 6f94a825485b1d622d8ebe88ddf3e2f426d1c69c Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Wed, 29 Nov 2023 15:48:26 +0100 Subject: update to axum 0.7 and cargo update --- src/main.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index e96b736..aab9df3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use std::env; +use std::net::SocketAddr; use std::sync::Arc; use axum::{Router, routing::post}; use axum::routing::{get, put}; @@ -24,7 +25,10 @@ mod error; mod services; #[tokio::main] -async fn main() { +async fn main() -> color_eyre::eyre::Result<()> { + + color_eyre::install()?; + unsafe { local_offset::set_soundness(local_offset::Soundness::Unsound); } let time_format = time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); @@ -64,14 +68,15 @@ async fn main() { let addr = SETTINGS.get_string("serveraddr").unwrap_or("0.0.0.0:7229".to_string()); info!("start server on {}", addr); - axum::Server::bind(&addr.parse().unwrap()) - .serve(app.into_make_service()) - .await - .unwrap(); + let listener = tokio::net::TcpListener::bind(addr.parse::()?) + .await?; + axum::serve(listener, app).await?; + + Ok(()) } pub struct AppState { db: PgPool, ping_send: Sender, ping_map: PingMap, -} \ No newline at end of file +} -- cgit v1.2.3