Skip to content

Commit

Permalink
feat: graceful shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
frectonz committed Aug 7, 2024
1 parent d83b0b4 commit 9f44ef8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ async fn main() -> color_eyre::Result<()> {
}

let address = args.address.parse::<std::net::SocketAddr>()?;
warp::serve(routes).run(address).await;
let (_, fut) = warp::serve(routes).bind_with_graceful_shutdown(address, async move {
tokio::signal::ctrl_c()
.await
.expect("failed to listen to shutdown signal");
});

fut.await;
println!();
tracing::info!("shutting down...");

Ok(())
}
Expand Down

0 comments on commit 9f44ef8

Please sign in to comment.