Skip to content

Commit

Permalink
Start the profiling server properly (#4271)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Apolinario <[email protected]>
Co-authored-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
eapolinario and eapolinario authored Oct 20, 2023
1 parent 8749fce commit e2b1b0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions cmd/single/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,7 @@ func startPropeller(ctx context.Context, cfg Propeller) error {
}

g.Go(func() error {
err := profutils.StartProfilingServerWithDefaultHandlers(childCtx, propellerCfg.ProfilerPort.Port, handlers)
if err != nil {
logger.Fatalf(childCtx, "Failed to Start profiling and metrics server. Error: %v", err)
}
return err
return profutils.StartProfilingServerWithDefaultHandlers(childCtx, propellerCfg.ProfilerPort.Port, handlers)
})

g.Go(func() error {
Expand Down
8 changes: 4 additions & 4 deletions flytestdlib/profutils/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ func StartProfilingServer(ctx context.Context, pprofPort int) error {
}

go func() {
e := srv.ListenAndServe()
if e != nil {
logger.Errorf(ctx, "Failed to start profiling server. Error: %v", e)
<-ctx.Done()
if err := srv.Shutdown(context.Background()); err != nil {
logger.Errorf(ctx, "Failed to gracefully shutdown profiling server. Error: %v", err)
}
}()

return srv.Shutdown(ctx)
return srv.ListenAndServe()
}

func configureGlobalHTTPHandler(handlers map[string]http.Handler) error {
Expand Down

0 comments on commit e2b1b0a

Please sign in to comment.