From 26a42b6510c399c7000725ed05785ddc62b5a717 Mon Sep 17 00:00:00 2001 From: wjqserver <114663932+WJQSERVER@users.noreply.github.com> Date: Wed, 16 Apr 2025 15:47:46 +0800 Subject: [PATCH] add pprof for debug --- main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index e9b29a9..6baac20 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,8 @@ import ( "github.com/cloudwego/hertz/pkg/network/standard" "github.com/hertz-contrib/http2/factory" + + _ "net/http/pprof" ) var ( @@ -385,6 +387,7 @@ func main() { } else { r = server.New( server.WithHostPorts(addr), + server.WithTransport(standard.NewTransporter), ) } @@ -447,11 +450,18 @@ func main() { fmt.Printf("A Go Based High-Performance Github Proxy \n") fmt.Printf("Made by WJQSERVER-STUDIO\n") + if cfg.Server.Debug { + go func() { + http.ListenAndServe("localhost:6060", nil) + }() + } + r.Spin() defer logger.Close() defer func() { if hertZfile != nil { - err := hertZfile.Close() + var err error + err = hertZfile.Close() if err != nil { logError("Failed to close hertz log file: %v", err) }