Set up dockerfile, and handle SIGINT signals

This commit is contained in:
Ben Grant 2023-05-16 15:36:53 +10:00
parent f78d762999
commit 65619653c6
4 changed files with 41 additions and 3 deletions

View file

@ -89,7 +89,7 @@ async fn main() {
.layer(rate_limit)
.layer(TraceLayer::new_for_http());
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
println!(
"🦀 Crab Fit API listening at http://{} in {} mode",
@ -102,6 +102,11 @@ async fn main() {
);
Server::bind(&addr)
.serve(app.into_make_service_with_connect_info::<SocketAddr>())
.with_graceful_shutdown(async {
tokio::signal::ctrl_c()
.await
.expect("Failed to install Ctrl+C handler")
})
.await
.unwrap();
}