-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path99-debug.go
46 lines (39 loc) · 1.11 KB
/
99-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
39
40
41
42
43
44
45
46
// +build debug
// Build with "make debug" to get access to the /debugging url
package main
import (
"flag"
"fmt"
"log"
"net/http/pprof"
_ "net/http/pprof"
"time"
)
func init() {
go func() {
time.Sleep(time.Second * 1)
fmt.Println("DEBUG BUILD")
fmt.Println("DEBUG BUILD")
fmt.Println("DEBUG BUILD")
fmt.Println("DEBUG BUILD")
}()
log.SetFlags(log.LstdFlags + log.Llongfile)
fmt.Println("DEBUG BUILD")
flag.Usage = func() {
fmt.Println("DEBUG BUILD")
}
}
func (c *Cosgo) debug() {
fmt.Println("Registering /debug/pprof/ URL handlers")
c.r.HandleFunc("/debug/pprof/", pprof.Index)
c.r.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
c.r.HandleFunc("/debug/pprof/profile", pprof.Profile)
c.r.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
c.r.Handle("/debug/pprof/heap", pprof.Handler("heap"))
c.r.Handle("/debug/pprof/block", pprof.Handler("block"))
c.r.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
c.r.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
c.r.HandleFunc("/debug/pprof/trace", pprof.Trace)
c.r.Handle("/profilez", pprof.Handler("profilez"))
return
}