Skip to content

Commit 13631b4

Browse files
committed
Take down the server if the request logging fails
1 parent 24decf1 commit 13631b4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ui/src/server_axum.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use std::{
3838
sync::{Arc, LazyLock},
3939
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
4040
};
41-
use tokio::sync::Mutex;
41+
use tokio::{select, sync::Mutex};
4242
use tower_http::{
4343
cors::{self, CorsLayer},
4444
request_id::{MakeRequestUuid, PropagateRequestIdLayer, SetRequestIdLayer},
@@ -71,7 +71,7 @@ pub(crate) async fn serve(config: Config) {
7171
let factory = Factory(Arc::new(config.coordinator_factory()));
7272

7373
let request_db = config.request_database();
74-
let (_db_task, db_handle) = request_db.spawn();
74+
let (db_task, db_handle) = request_db.spawn();
7575

7676
let root_files = static_file_service(config.root_path(), MAX_AGE_ONE_DAY);
7777
let asset_files = static_file_service(config.asset_path(), MAX_AGE_ONE_YEAR);
@@ -170,9 +170,12 @@ pub(crate) async fn serve(config: Config) {
170170
.await
171171
.unwrap();
172172

173-
axum::serve(listener, app.into_make_service())
174-
.await
175-
.unwrap();
173+
let server = axum::serve(listener, app.into_make_service());
174+
175+
select! {
176+
v = server => v.unwrap(),
177+
v = db_task => v.unwrap(),
178+
}
176179
}
177180

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

0 commit comments

Comments
 (0)