Skip to content

Commit

Permalink
add GracefulStop
Browse files Browse the repository at this point in the history
  • Loading branch information
lghinet committed Jul 12, 2022
1 parent 33af11c commit b9caf03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 0 additions & 5 deletions cmd/rusid/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
//_ "net/http/pprof"
"os"
"os/signal"
"runtime/debug"
"rusi/internal/diagnostics"
"rusi/internal/metrics"
"rusi/internal/tracing"
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions pkg/api/runtime/grpc/grpc_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}()

Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit b9caf03

Please sign in to comment.