MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / stopServerWithContext

Method stopServerWithContext

sdk/cliproxy/pprof_server.go:131–147  ·  view source on GitHub ↗
(ctx context.Context, server *http.Server, addr string, reason string)

Source from the content-addressed store, hash-verified

129}
130
131func (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
149func newPprofMux() *http.ServeMux {
150 mux := http.NewServeMux()

Callers 2

ShutdownMethod · 0.95
stopServerMethod · 0.95

Calls 1

ShutdownMethod · 0.65

Tested by

no test coverage detected