fix: stop server on SIGINT

This commit is contained in:
Timo Ley 2023-06-22 17:55:18 +02:00
parent 26f4070d69
commit b29eb76b2d

View file

@ -7,6 +7,7 @@ use sibyl::{Environment, SessionPool};
use structopt::{StructOpt, lazy_static::lazy_static};
use config::Config;
use tokio::signal;
use tower_http::set_header::SetResponseHeaderLayer;
mod config;
@ -54,8 +55,14 @@ async fn main() -> Result<(), ApplicationError> {
));
axum::Server::bind(&config.addr)
.serve(app.into_make_service())
.await?;
.serve(app.into_make_service()).with_graceful_shutdown(shutdown()).await?;
Ok(())
}
async fn shutdown() {
match signal::ctrl_c().await {
Ok(()) => {},
Err(err) => {},
}
}