add pprof for debug

This commit is contained in:
wjqserver 2025-04-16 15:47:46 +08:00
parent 254c9a8bad
commit 26a42b6510

12
main.go
View file

@ -28,6 +28,8 @@ import (
"github.com/cloudwego/hertz/pkg/network/standard" "github.com/cloudwego/hertz/pkg/network/standard"
"github.com/hertz-contrib/http2/factory" "github.com/hertz-contrib/http2/factory"
_ "net/http/pprof"
) )
var ( var (
@ -385,6 +387,7 @@ func main() {
} else { } else {
r = server.New( r = server.New(
server.WithHostPorts(addr), 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("A Go Based High-Performance Github Proxy \n")
fmt.Printf("Made by WJQSERVER-STUDIO\n") fmt.Printf("Made by WJQSERVER-STUDIO\n")
if cfg.Server.Debug {
go func() {
http.ListenAndServe("localhost:6060", nil)
}()
}
r.Spin() r.Spin()
defer logger.Close() defer logger.Close()
defer func() { defer func() {
if hertZfile != nil { if hertZfile != nil {
err := hertZfile.Close() var err error
err = hertZfile.Close()
if err != nil { if err != nil {
logError("Failed to close hertz log file: %v", err) logError("Failed to close hertz log file: %v", err)
} }