aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-09 20:02:30 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-09 20:02:30 +0800
commit5ec84ffa3f06295ef3d93f7db18f7e0e9ed184eb (patch)
tree21693fccf119b3431160012c08ea66c6db3eb20f
parentindex: Rename gc button again (diff)
downloadforge-5ec84ffa3f06295ef3d93f7db18f7e0e9ed184eb.tar.gz
forge-5ec84ffa3f06295ef3d93f7db18f7e0e9ed184eb.tar.zst
forge-5ec84ffa3f06295ef3d93f7db18f7e0e9ed184eb.zip
main: Add pprof listener for performance debugging
-rw-r--r--main.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/main.go b/main.go
index cba6e1b..5e836f1 100644
--- a/main.go
+++ b/main.go
@@ -11,6 +11,7 @@ import (
"syscall"
"go.lindenii.runxiyu.org/lindenii-common/clog"
+ _ "net/http/pprof"
)
func main() {
@@ -93,5 +94,17 @@ func main() {
}
}()
+ // Pprof listener
+ pprof_listener, err := net.Listen("tcp", "localhost:6060")
+ if err != nil {
+ clog.Fatal(1, "Listening pprof: "+err.Error())
+ }
+ clog.Info("Listening pprof on tcp localhost:6060")
+ go func() {
+ if err = http.Serve(pprof_listener, nil); err != nil {
+ clog.Fatal(1, "Serving pprof: "+err.Error())
+ }
+ }()
+
select {}
}