Skip to content

Commit

Permalink
Support enable pprof
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jun 14, 2024
1 parent 7bb4757 commit cb1a8c0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/crproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"net"
"net/http"
"net/http/pprof"
"net/url"
"os"
"slices"
Expand Down Expand Up @@ -43,6 +44,7 @@ var (
linkExpires time.Duration
redirectLinks string
disableTagsList bool
enablePprof bool
)

func init() {
Expand All @@ -63,6 +65,7 @@ func init() {
pflag.DurationVar(&linkExpires, "link-expires", 0, "link expires")
pflag.StringVar(&redirectLinks, "redirect-links", "", "redirect links")
pflag.BoolVar(&disableTagsList, "disable-tags-list", false, "disable tags list")
pflag.BoolVar(&enablePprof, "enable-pprof", false, "Enable pprof")
pflag.Parse()
}

Expand Down Expand Up @@ -220,6 +223,14 @@ func main() {

mux.Handle("/v2/", crp)

if enablePprof {
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
}

var handler http.Handler = mux
handler = handlers.LoggingHandler(os.Stderr, handler)
if behind {
Expand Down

0 comments on commit cb1a8c0

Please sign in to comment.