(ctx context.Context, server *http.Server, addr string, reason string)
| 129 | } |
| 130 | |
| 131 | func (p *pprofServer) stopServerWithContext(ctx context.Context, server *http.Server, addr string, reason string) error { |
| 132 | if server == nil { |
| 133 | return nil |
| 134 | } |
| 135 | stopCtx := ctx |
| 136 | if stopCtx == nil { |
| 137 | stopCtx = context.Background() |
| 138 | } |
| 139 | stopCtx, cancel := context.WithTimeout(stopCtx, 5*time.Second) |
| 140 | defer cancel() |
| 141 | if errStop := server.Shutdown(stopCtx); errStop != nil { |
| 142 | log.Errorf("pprof server stop failed on %s: %v", addr, errStop) |
| 143 | return errStop |
| 144 | } |
| 145 | log.Infof("pprof server stopped on %s (%s)", addr, reason) |
| 146 | return nil |
| 147 | } |
| 148 | |
| 149 | func newPprofMux() *http.ServeMux { |
| 150 | mux := http.NewServeMux() |
no test coverage detected