diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 11 insertions, 6 deletions
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 @@ | |||
1 | use std::env; | 1 | use std::env; |
2 | use std::net::SocketAddr; | ||
2 | use std::sync::Arc; | 3 | use std::sync::Arc; |
3 | use axum::{Router, routing::post}; | 4 | use axum::{Router, routing::post}; |
4 | use axum::routing::{get, put}; | 5 | use axum::routing::{get, put}; |
@@ -24,7 +25,10 @@ mod error; | |||
24 | mod services; | 25 | mod services; |
25 | 26 | ||
26 | #[tokio::main] | 27 | #[tokio::main] |
27 | async fn main() { | 28 | async fn main() -> color_eyre::eyre::Result<()> { |
29 | |||
30 | color_eyre::install()?; | ||
31 | |||
28 | unsafe { local_offset::set_soundness(local_offset::Soundness::Unsound); } | 32 | unsafe { local_offset::set_soundness(local_offset::Soundness::Unsound); } |
29 | let time_format = | 33 | let time_format = |
30 | time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); | 34 | time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); |
@@ -64,14 +68,15 @@ async fn main() { | |||
64 | 68 | ||
65 | let addr = SETTINGS.get_string("serveraddr").unwrap_or("0.0.0.0:7229".to_string()); | 69 | let addr = SETTINGS.get_string("serveraddr").unwrap_or("0.0.0.0:7229".to_string()); |
66 | info!("start server on {}", addr); | 70 | info!("start server on {}", addr); |
67 | axum::Server::bind(&addr.parse().unwrap()) | 71 | let listener = tokio::net::TcpListener::bind(addr.parse::<SocketAddr>()?) |
68 | .serve(app.into_make_service()) | 72 | .await?; |
69 | .await | 73 | axum::serve(listener, app).await?; |
70 | .unwrap(); | 74 | |
75 | Ok(()) | ||
71 | } | 76 | } |
72 | 77 | ||
73 | pub struct AppState { | 78 | pub struct AppState { |
74 | db: PgPool, | 79 | db: PgPool, |
75 | ping_send: Sender<BroadcastCommands>, | 80 | ping_send: Sender<BroadcastCommands>, |
76 | ping_map: PingMap, | 81 | ping_map: PingMap, |
77 | } \ No newline at end of file | 82 | } |