-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.go
38 lines (32 loc) · 653 Bytes
/
debug.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
_ "expvar"
"net/http"
_ "net/http/pprof" //nolint:gosec // profiling is enabled via CLI flag
"time"
)
/*
Available server endpoints:
- /debug/pprof
- /debug/pprof/cmdline
- /debug/pprof/profile
- /debug/pprof/symbol
- /debug/pprof/trace
- /debug/vars
*/
const defaultServerReadHeaderTimeout = 5 * time.Second
func debug(addr string) {
if addr == "" {
return
}
server := &http.Server{
Addr: addr,
ReadHeaderTimeout: defaultServerReadHeaderTimeout,
}
go func() {
err := server.ListenAndServe()
if err != nil {
cl.Errorf("Failed to start `/debug` web server: %s", err)
}
}()
}