Gracefully shutdown on SIGINT.
This commit is contained in:
parent
460c002145
commit
aa5aaf816f
|
@ -46,10 +46,16 @@ async fn main() {
|
|||
|
||||
let app = Router::new().route("/", get(root_get)).with_state(state);
|
||||
|
||||
let quit_signal = async {
|
||||
_ = tokio::signal::ctrl_c().await;
|
||||
eprintln!("Initializing graceful shutdown");
|
||||
};
|
||||
|
||||
let addr = "0.0.0.0:8080".parse().unwrap();
|
||||
info!("Listening on {addr}");
|
||||
axum::Server::bind(&addr)
|
||||
.serve(app.into_make_service())
|
||||
.with_graceful_shutdown(quit_signal)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue