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

Method startServer

sdk/cliproxy/pprof_server.go:98–125  ·  view source on GitHub ↗
(addr string)

Source from the content-addressed store, hash-verified

96}
97
98func (p *pprofServer) startServer(addr string) {
99 mux := newPprofMux()
100 server := &http.Server{
101 Addr: addr,
102 Handler: mux,
103 ReadHeaderTimeout: 5 * time.Second,
104 }
105
106 p.mu.Lock()
107 if !p.enabled || p.addr != addr || p.server != nil {
108 p.mu.Unlock()
109 return
110 }
111 p.server = server
112 p.mu.Unlock()
113
114 log.Infof("pprof server starting on %s", addr)
115 go func() {
116 if errServe := server.ListenAndServe(); errServe != nil && !errors.Is(errServe, http.ErrServerClosed) {
117 log.Errorf("pprof server failed on %s: %v", addr, errServe)
118 p.mu.Lock()
119 if p.server == server {
120 p.server = nil
121 }
122 p.mu.Unlock()
123 }
124 }()
125}
126
127func (p *pprofServer) stopServer(server *http.Server, addr string, reason string) {
128 _ = p.stopServerWithContext(context.Background(), server, addr, reason)

Callers 1

ApplyMethod · 0.95

Calls 1

newPprofMuxFunction · 0.85

Tested by

no test coverage detected