You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using tonic to build a service, I want to shutdown gracefully:
step 1: close all connections with deadline 10 seconds.
step 2: save data to disk.
when I use following code:
Server::builder()
.add_service(GameServer::new(game))
.serve_with_shutdown(addr, async {
println!("waiting ctrl+C...");
tokio::spawn(tokio::signal::ctrl_c()).await;
println!("after ctrl+C!");
// how to disconnect all connections ? ...
// save data to disk...
// handler1.abort();
});
if I press Ctrl+C to abort client first, then press Ctrl+C to abort server, all is ok. but when I press Ctrl+C to abort server first, it will execute to "after Ctrl+C" and continue send data to client, don't close connections and exit.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am using tonic to build a service, I want to shutdown gracefully:
step 1: close all connections with deadline 10 seconds.
step 2: save data to disk.
when I use following code:
if I press Ctrl+C to abort client first, then press Ctrl+C to abort server, all is ok. but when I press Ctrl+C to abort server first, it will execute to "after Ctrl+C" and continue send data to client, don't close connections and exit.
I tried to test hyper, that's ok. so I don't clear what happened in tonic.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d3a753d783d94132f171c4ae5528ebd0
tonic test code in attachment:
test-tonic.tar.gz
Beta Was this translation helpful? Give feedback.
All reactions