| 12345678910111213141516171819202122232425 |
- package pprof
- import (
- "net"
- "net/http"
- "git.shuncheng.lu/bigthing/gocommon/pkg/internal/util"
- _ "net/http/pprof"
- )
- func Init() error {
- listener, err := net.Listen("tcp", ":0")
- if err != nil {
- return err
- }
- util.Infof("[pprof] listener port: %d", listener.Addr().(*net.TCPAddr).Port)
- go func() {
- err := http.Serve(listener, nil)
- if err != nil {
- util.Errorf("[pprof] serve err, err: %s", err)
- }
- }()
- return nil
- }
|