This commit is contained in:
maurice committed 2026-11-14 19:33:06 +01:00
1 parent e1bb3a253c
commit 3d9777d81a
3 files changed
+41 -2

No files matched your search

+19 -1
View File
@@ -53,6 +53,24 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let port = std::env::var("PORT").unwrap_or_else(|_| "3000".to_owned());
let listener = TcpListener::bind(format!("0.0.0.0:{port}")).await?;
println!("Listening on http://localhost:{port}");
serve(listener, app).await?;
serve(listener, app)
.with_graceful_shutdown(shutdown_signal())
.await?;
Ok(())
}
async fn shutdown_signal() {
let terminate = async {
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
.expect("Failed to install SIGTERM handler")
.recv()
.await;
};
tokio::select! {
result = tokio::signal::ctrl_c() => {
result.expect("Failed to install Ctrl+C handler");
}
_ = terminate => {}
}
}