Skip to content

Commit

Permalink
Take down the server if the request logging fails
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Nov 18, 2024
1 parent 24decf1 commit 13631b4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ui/src/server_axum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use std::{
sync::{Arc, LazyLock},
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
};
use tokio::sync::Mutex;
use tokio::{select, sync::Mutex};
use tower_http::{
cors::{self, CorsLayer},
request_id::{MakeRequestUuid, PropagateRequestIdLayer, SetRequestIdLayer},
Expand Down Expand Up @@ -71,7 +71,7 @@ pub(crate) async fn serve(config: Config) {
let factory = Factory(Arc::new(config.coordinator_factory()));

let request_db = config.request_database();
let (_db_task, db_handle) = request_db.spawn();
let (db_task, db_handle) = request_db.spawn();

let root_files = static_file_service(config.root_path(), MAX_AGE_ONE_DAY);
let asset_files = static_file_service(config.asset_path(), MAX_AGE_ONE_YEAR);
Expand Down Expand Up @@ -170,9 +170,12 @@ pub(crate) async fn serve(config: Config) {
.await
.unwrap();

axum::serve(listener, app.into_make_service())
.await
.unwrap();
let server = axum::serve(listener, app.into_make_service());

select! {
v = server => v.unwrap(),
v = db_task => v.unwrap(),
}
}

fn get_or_post<T: 'static>(handler: impl Handler<T, ()> + Copy) -> MethodRouter {
Expand Down

0 comments on commit 13631b4

Please sign in to comment.