Is there a provision in grpc-java to add new services to grpc servers during runtime

22 views
Skip to first unread message

Darshan J

unread,
Jun 19, 2024, 1:56:42 AM (14 days ago) Jun 19
to grpc.io

Hi guys,
I want to add and remove services to the grpc server without bringing down other services running.

Usecase: Whenever I need to use grpcurl or grpcdebug for debugging purposes, these tools require like ProtoReflectionService, AdminInterface.getStandardServices and so on. If my server is already running with my critical services. How to add other services and also after adding new services will I be able to remove it without bringing down the critical services.

Due to some contraints I do not wish to add it along with critical services during first-time server bring up only in specific ocassions like during debugging I would like to add it and remove when purpose is over.

Thanks and Regards, 
Darshan J Gowda

Larry Safran

unread,
Jun 20, 2024, 5:41:26 PM (12 days ago) Jun 20
to Darshan J, grpc.io
You can run multiple Server instances from the same application to get dynamic management like that, as long as you use a different port for the debug services and the critical services. 

    prodServer = Grpc.newServerBuilderForPort(50051, InsecureServerCredentials.create())
        .addService(new GreeterImpl())
        .build()
        .start();

....
  Server startDebugServer() {
      dubugServer = Grpc.newServerBuilderForPort(50052, InsecureServerCredentials.create())
        .addService(AdminInterface.getStandardServices())
        .build()
        .start();
      return debugServer;
  }

void shutdownDebugServer(Server debugServer) {
  debugServer.shutdownNow();
  debugServer.awaitTermination();
}

Hope that helps,
  Larry

--
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 grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/3e107efd-e7a1-4c53-8099-cea888846a44n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages