protected void stopAndReleaseGrpcServer() {
        final Server localServer = this.server;
        if (localServer != null) {
            final long millis = this.shutdownGracePeriod.toMillis();
            log.debug("Initiating gRPC server shutdown");
            this.eventPublisher.publishEvent(new GrpcServerShutdownEvent(this, localServer));
            localServer.shutdown();
            // Wait for the server to shutdown completely before continuing with destroying the spring context
            try {
                if (millis > 0) {
                    localServer.awaitTermination(millis, MILLISECONDS);
                } else if (millis == 0) {
                    // Do not wait
                } else {
                    // Wait infinitely
                    localServer.awaitTermination();
                }
            } catch (final InterruptedException e) {
                Thread.currentThread().interrupt();
            } finally {
                localServer.shutdownNow();
                this.server = null;
            }
            log.info("Completed gRPC server shutdown");
            this.eventPublisher.publishEvent(new GrpcServerTerminatedEvent(this, localServer));
        }
    }
Initiates an orderly shutdown of the grpc server and releases the references to the server. This call waits for
the server to be completely shut down.
grpc-server-spring-boot-starter/src/main/java/net/devh/boot/grpc/server/serverfactory/GrpcServerLifecycle.java