From a57e522a6749658d1268beca4019640d4dbcdda5 Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 5 Jul 2021 17:31:41 +0200 Subject: [PATCH 1/2] introduce a die route let the program exit itself alone --- http-ui/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/http-ui/src/main.rs b/http-ui/src/main.rs index d0fc29573..f9f3a3c52 100644 --- a/http-ui/src/main.rs +++ b/http-ui/src/main.rs @@ -982,6 +982,11 @@ async fn main() -> anyhow::Result<()> { }) }); + let die_route = warp::filters::method::get().and(warp::path!("die")).map(move || { + std::process::exit(0); + warp::reply() + }); + let routes = dash_html_route .or(updates_list_or_html_route) .or(dash_bulma_route) @@ -1001,7 +1006,8 @@ async fn main() -> anyhow::Result<()> { .or(clearing_route) .or(change_settings_route) .or(change_facet_levels_route) - .or(update_ws_route); + .or(update_ws_route) + .or(die_route); let addr = SocketAddr::from_str(&opt.http_listen_addr)?; warp::serve(routes).run(addr).await; From 4562b278a8fa3d10601a541f25ce0eaa3f0b1997 Mon Sep 17 00:00:00 2001 From: Irevoire Date: Mon, 5 Jul 2021 17:43:28 +0200 Subject: [PATCH 2/2] remove a warning and add a log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Renault --- http-ui/src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/http-ui/src/main.rs b/http-ui/src/main.rs index f9f3a3c52..ee32882c0 100644 --- a/http-ui/src/main.rs +++ b/http-ui/src/main.rs @@ -983,7 +983,9 @@ async fn main() -> anyhow::Result<()> { }); let die_route = warp::filters::method::get().and(warp::path!("die")).map(move || { + eprintln!("Killed by an HTTP request received on the die route"); std::process::exit(0); + #[allow(unreachable_code)] warp::reply() });