Thanks, Yeah, my main question was around whether server,shutdown can be called before we cleanup the services. Your answer helps.
On Thu, Dec 7, 2017 at 3:44 PM, Eric Anderson <[email protected]> wrote: > On Thu, Nov 23, 2017 at 12:41 AM, Rama Rao <[email protected]> > wrote: > >> Now if I want to graceful shutdown, do I have first call shutdown on >> each of the services added to ServiceImpl and then follow-it with a call to >> service.shutdown? >> or service.shutdown will handle both the cases? >> > > There isn't a `*service*.shutdown()`, just *server* (unless you made it, > and then I won't know what it does). I think you should do things in the > opposite order: first shut down the server, then the services. > > I'd expect the normal flow to be: > > server.shutdown(); // This simply prevents new RPCs > server.awaitTermination(5, SECONDS); // This is the grace time > server.shutdownNow(); // This kills all RPCs > // This needs some time to queue cancellation notifications. > // Note that terminated does not imply the *application* is done > processing. > // It only means the server won't issue any more work to the application. > if (!server.awaitTermination(1, SECONDS)) { > log.log(WARNING, "For some reason the server didn't shutdown promptly"); > } > // After the server is terminated, all work has at least been queued onto > the server's executor. > // You can shutdown and wait on that executor if you want. You can then > also clean up services. > cleanUpServices(); > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAFfmCFHWzVn-Ch%2By9%3DfTfqz4oebmdeA1z%3D4zJP-kV0rWLKX1uw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
