fix: stop server on SIGINT
This commit is contained in:
parent
26f4070d69
commit
b29eb76b2d
1 changed files with 9 additions and 2 deletions
11
src/main.rs
11
src/main.rs
|
@ -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) => {},
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue