-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to shut down the server? #307
Comments
Hey! Tarpc doesn't build in any shutdown functionality, because different people may want different behavior. But, adding it yourself via native futures/streams features wouldn't be too hard; it just kind of depends what you mean by shutdown. Are you interested in...
One simple approach is to just make your server future abortable. If you're spawning client connections onto different tasks, you'd need to take some extra steps to shut down those connections. |
Either approach would work for me, but with preference to the lameduck mode. I'll take a look at abortable, thanks. Maybe this would be helpful here? https://github.com/jonhoo/stream-cancel |
|
Hey @tikue, here's what I ended up going with: async fn start_abortable_tcp_server(addr: SocketAddr, exit: Arc<AtomicBool>) {
let server = start_tcp_server(addr).fuse();
let interval = time::interval(Duration::from_millis(100)).fuse();
pin_mut!(server, interval);
loop {
select! {
_ = server => {},
_ = interval.select_next_some() => {
if exit.load(Ordering::Relaxed) {
break;
}
}
}
}
} Not a graceful shutdown, but gets the job done. |
Looking at HelloServer in example-service, how would one add a "Press to shut down" feature?
The text was updated successfully, but these errors were encountered: