Open yhl25 opened 2 months ago
That isn't directly supported right now, but would be possible to add. I think I hesitate to say "lets just add it" because the ecosystem for hyper servers is pretty unstable right now, hence tonic currently implements its own graceful shutdown.
You could also implement it yourself by wrapping around Server
. You'd want a future which waits for your shutdown signal, then waits for the timeout. Then you'd use tokio::select!
on that + the server, and bail as soon as either future finishes, dropping the server, cancelling any remaining futures.
Version
latest
Description
I'm currently working with tonic for implementing gRPC services in Rust, and I've encountered a situation where the server might not shut down gracefully due to long-running or unresponsive RPC connections.
I tried this code:
I have updated the bi-directional streaming example with custom shutdown logic, where the server shutdown is expected to be triggered based on a signal. This works as expected until a stream connection remains active indefinitely, causing the server to not shutdown.
However, if some RPC is abnormally pending for a long time, the server has to wait. Can I set a timeout for the graceful shutdown?