From dc6be5d1b073d87b2405d84d33f5bb5f6ced490e Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 10 Sep 2018 13:26:53 -0400 Subject: [PATCH] api: remove handleShutdown func This function was used for handling errors in the graceful library and was never necessary for the v3 API. --- api/v3/server.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/api/v3/server.go b/api/v3/server.go index cdf356b7..29c478b9 100644 --- a/api/v3/server.go +++ b/api/v3/server.go @@ -35,15 +35,6 @@ import ( "github.com/coreos/clair/database" ) -// handleShutdown handles the server shut down error. -func handleShutdown(err error) { - if err != nil { - if opErr, ok := err.(*net.OpError); !ok || (ok && opErr.Op != "accept") { - log.Fatal(err) - } - } -} - var ( promResponseDurationMilliseconds = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: "clair_v3_api_response_duration_milliseconds", @@ -178,7 +169,7 @@ func Run(Addr string, tlsConfig *tls.Config, CertFile, KeyFile string, store dat tlsConfig.NextProtos = []string{"h2"} apiListener = tls.NewListener(tcpMux.Match(cmux.Any()), tlsConfig) - go func() { handleShutdown(tcpMux.Serve()) }() + go func() { tcpMux.Serve() }() grpcServer := newGrpcServer(store, tlsConfig) gwmux := newGrpcGatewayServer(ctx, apiListener.Addr().String(), tlsConfig) @@ -191,10 +182,10 @@ func Run(Addr string, tlsConfig *tls.Config, CertFile, KeyFile string, store dat } else { grpcL := tcpMux.Match(cmux.HTTP2HeaderField("content-type", "application/grpc")) apiListener = tcpMux.Match(cmux.Any()) - go func() { handleShutdown(tcpMux.Serve()) }() + go func() { tcpMux.Serve() }() grpcServer := newGrpcServer(store, nil) - go func() { handleShutdown(grpcServer.Serve(grpcL)) }() + go func() { grpcServer.Serve(grpcL) }() gwmux := newGrpcGatewayServer(ctx, apiListener.Addr().String(), nil) @@ -211,7 +202,7 @@ func Run(Addr string, tlsConfig *tls.Config, CertFile, KeyFile string, store dat } // blocking call - handleShutdown(srv.Serve(apiListener)) + srv.Serve(apiListener) log.Info("Grpc API stopped") }