From c1e3172e3a7157e812c5c76eaedc9a97fe257716 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 16 Jun 2017 11:50:32 -0700 Subject: [PATCH] etcdserver/api/v3rpc: add default grpc health service --- etcdserver/api/v3rpc/grpc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/etcdserver/api/v3rpc/grpc.go b/etcdserver/api/v3rpc/grpc.go index ba0d331e8..10d58a880 100644 --- a/etcdserver/api/v3rpc/grpc.go +++ b/etcdserver/api/v3rpc/grpc.go @@ -19,9 +19,12 @@ import ( "github.com/coreos/etcd/etcdserver" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" + "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/health" + healthpb "google.golang.org/grpc/health/grpc_health_v1" ) const grpcOverheadBytes = 512 * 1024 @@ -48,5 +51,12 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config) *grpc.Server { pb.RegisterAuthServer(grpcServer, NewAuthServer(s)) pb.RegisterMaintenanceServer(grpcServer, NewMaintenanceServer(s)) + // server should register all the services manually + // use empty service name for all etcd services' health status, + // see https://github.com/grpc/grpc/blob/master/doc/health-checking.md for more + hsrv := health.NewServer() + hsrv.SetServingStatus("", healthpb.HealthCheckResponse_SERVING) + healthpb.RegisterHealthServer(grpcServer, hsrv) + return grpcServer }