Skip to content

Commit

Permalink
etcdmain: add '/health' endpoint to grpc-proxy
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <[email protected]>
  • Loading branch information
gyuho committed Jul 28, 2017
1 parent 2a6191f commit 2b7dec2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions etcdmain/grpc_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func startGRPCProxy(cmd *cobra.Command, args []string) {

client := mustNewClient()

srvhttp, httpl := mustHTTPListener(m, tlsinfo)
srvhttp, httpl := mustHTTPListener(m, tlsinfo, client)
errc := make(chan error)
go func() { errc <- newGRPCProxyServer(client).Serve(grpcl) }()
go func() { errc <- srvhttp.Serve(httpl) }()
Expand All @@ -157,7 +157,7 @@ func startGRPCProxy(cmd *cobra.Command, args []string) {
mhttpl := mustMetricsListener(tlsinfo)
go func() {
mux := http.NewServeMux()
etcdhttp.HandlePrometheus(mux)
etcdhttp.HandleMetricsHealth(mux, client)
plog.Fatal(http.Serve(mhttpl, mux))
}()
}
Expand Down Expand Up @@ -290,10 +290,10 @@ func newGRPCProxyServer(client *clientv3.Client) *grpc.Server {
return server
}

func mustHTTPListener(m cmux.CMux, tlsinfo *transport.TLSInfo) (*http.Server, net.Listener) {
func mustHTTPListener(m cmux.CMux, tlsinfo *transport.TLSInfo, cli *clientv3.Client) (*http.Server, net.Listener) {
httpmux := http.NewServeMux()
httpmux.HandleFunc("/", http.NotFound)
etcdhttp.HandlePrometheus(httpmux)
etcdhttp.HandleMetricsHealth(httpmux, cli)
if grpcProxyEnablePprof {
for p, h := range debugutil.PProfHandlers() {
httpmux.Handle(p, h)
Expand Down

0 comments on commit 2b7dec2

Please sign in to comment.