I'm wondering if there is a way to gracefully shut down a gRPC server.
Server.Stop() [1] appears to immediately close all existing
connections. Aside from a few streaming file upload / download
operations, all of my RPC handler functions set internal deadlines via
[2] so I'd like to see those complete successfully. Am I just
misreading Stop() or is there no way to stop accepting connections and
allow the server to drain gracefully before returning?
My second question: given a running Server with a registered service
X, is it possible to bind a different instance of service X to the
server? [3] Or should I call Server.Stop() then create a new server
and register the new instance to that one? Do I need to close and
reopen the listener?
The background here is that I have a "degraded" mode for my service
and it is easier to implement this as a completely different gRPC
server. However I would like to make handoff between the two modes as
clean as possible.
Thanks for your help!
~ Scott
[1]:
https://godoc.org/google.golang.org/grpc#Server.Stop
[2]:
https://godoc.org/golang.org/x/net/context#WithDeadline
[3]:
https://godoc.org/google.golang.org/grpc#Server.RegisterService