Skip to content

Commit b264776

Browse files
committed
Better shutdown handling
1 parent 5d6d142 commit b264776

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,17 @@ async fn main() -> anyhow::Result<()> {
8585

8686
info!("Server started on {}", state.environment.port);
8787

88-
axum::serve::serve(listener, app).await?;
88+
let mut sigterm = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())?;
89+
90+
tokio::select! {
91+
_ = axum::serve::serve(listener, app) => {},
92+
_ = tokio::signal::ctrl_c() => {
93+
info!("Shutting down");
94+
},
95+
_ = sigterm.recv() => {
96+
info!("Shutting down");
97+
}
98+
}
8999

90100
Ok(())
91101
}

0 commit comments

Comments
 (0)