284: [http-ui] Introduce the route `die` r=Kerollmops a=irevoire

This route just `exit` the process. This can come in handy when you run `http-ui` inside of another process (a profiler for example), and you don't want to kill everything

Co-authored-by: Tamo <tamo@meilisearch.com>
Co-authored-by: Irevoire <tamo@meilisearch.com>
This commit is contained in:
bors[bot] 2021-07-05 15:47:53 +00:00 committed by GitHub
commit 63db43cc7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -982,6 +982,13 @@ 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()
});
let routes = dash_html_route let routes = dash_html_route
.or(updates_list_or_html_route) .or(updates_list_or_html_route)
.or(dash_bulma_route) .or(dash_bulma_route)
@ -1001,7 +1008,8 @@ async fn main() -> anyhow::Result<()> {
.or(clearing_route) .or(clearing_route)
.or(change_settings_route) .or(change_settings_route)
.or(change_facet_levels_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)?; let addr = SocketAddr::from_str(&opt.http_listen_addr)?;
warp::serve(routes).run(addr).await; warp::serve(routes).run(addr).await;