m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-10 14:13:49 -05:00

fix: add error message when app fails to bind to port

This commit is contained in:
Sergio
2025-03-15 12:15:33 +02:00
parent ffd4d6267c
commit 9f142ab81c

View File

@@ -19,6 +19,7 @@ use xitca_web::{
use crate::{ use crate::{
check::get_updates, check::get_updates,
config::Theme, config::Theme,
error,
structs::update::Update, structs::update::Update,
utils::{ utils::{
json::{to_full_json, to_simple_json}, json::{to_full_json, to_simple_json},
@@ -79,12 +80,16 @@ pub async fn serve(port: &u16, ctx: &Context) -> std::io::Result<()> {
.at("/", get(handler_service(_static))) .at("/", get(handler_service(_static)))
.at("/*", get(handler_service(_static))); .at("/*", get(handler_service(_static)));
} }
app_builder match app_builder
.enclosed_fn(logger) .enclosed_fn(logger)
.serve() .serve()
.bind(format!("0.0.0.0:{}", port))? .bind(format!("0.0.0.0:{}", port))
.run() {
.wait() Ok(r) => r,
Err(_) => error!("Failed to bind to port {}. Is it in use?", port),
}
.run()
.wait()
} }
async fn _static(data: StateRef<'_, Arc<Mutex<ServerData>>>, path: PathRef<'_>) -> WebResponse { async fn _static(data: StateRef<'_, Arc<Mutex<ServerData>>>, path: PathRef<'_>) -> WebResponse {