From b9caf03094c628d61c5aa058e5a6cf60440bba54 Mon Sep 17 00:00:00 2001 From: Honeypot Date: Tue, 12 Jul 2022 08:19:46 +0300 Subject: [PATCH] add GracefulStop --- cmd/rusid/sidecar.go | 5 ----- pkg/api/runtime/grpc/grpc_api.go | 7 +++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/rusid/sidecar.go b/cmd/rusid/sidecar.go index 9d03808..8fdf162 100644 --- a/cmd/rusid/sidecar.go +++ b/cmd/rusid/sidecar.go @@ -8,7 +8,6 @@ import ( //_ "net/http/pprof" "os" "os/signal" - "runtime/debug" "rusi/internal/diagnostics" "rusi/internal/metrics" "rusi/internal/tracing" @@ -105,10 +104,6 @@ func startDiagnosticsServer(ctx context.Context, wg *sync.WaitGroup, appId strin router := http.NewServeMux() router.Handle("/healthz", healthcheck.HandlerFunc(options...)) - router.HandleFunc("/gc", func(writer http.ResponseWriter, request *http.Request) { - debug.FreeOSMemory() - writer.WriteHeader(200) - }) if enableMetrics { exporter := metrics.SetupPrometheusMetrics(appId) diff --git a/pkg/api/runtime/grpc/grpc_api.go b/pkg/api/runtime/grpc/grpc_api.go index 5487aa7..e134ecb 100644 --- a/pkg/api/runtime/grpc/grpc_api.go +++ b/pkg/api/runtime/grpc/grpc_api.go @@ -56,8 +56,8 @@ func (srv *grpcApi) Serve(ctx context.Context) error { go func() { select { case <-ctx.Done(): - //grpcServer.GracefulStop() should also work - grpcServer.Stop() + grpcServer.GracefulStop() + //grpcServer.Stop() } }() @@ -164,6 +164,9 @@ func (srv *rusiServerImpl) Subscribe(stream v1.Rusi_SubscribeServer) error { _ = unsub() if exit { klog.V(4).InfoS("closing subscription stream", "topic", request.Topic, "error", err) + if errors.Is(err, context.Canceled) { + return nil + } return err } }