xds: add reflection and health service to example server (#3403)

This commit is contained in:
Menghan Li
2020-02-27 13:17:17 -08:00
committed by GitHub
parent f8ad812d8e
commit 224056d331

View File

@ -34,6 +34,9 @@ import (
"google.golang.org/grpc"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
"google.golang.org/grpc/health"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/reflection"
)
var help = flag.Bool("help", false, "Print usage information")
@ -124,6 +127,12 @@ func main() {
}
s := grpc.NewServer()
pb.RegisterGreeterServer(s, newServer(hostname))
reflection.Register(s)
healthServer := health.NewServer()
healthServer.SetServingStatus("", healthpb.HealthCheckResponse_SERVING)
healthpb.RegisterHealthServer(s, healthServer)
log.Printf("serving on %s, hostname %s", lis.Addr(), hostname)
s.Serve(lis)
}