-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhongyu mao
committed
Feb 20, 2024
1 parent
dda472c
commit 158cb31
Showing
7 changed files
with
111 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
User: cr-mao | ||
Date: 2024/2/20 11:55 | ||
Email: crmao@qq.com | ||
Desc: pprof.go | ||
*/ | ||
package pprof_server | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"net/http" | ||
_ "net/http/pprof" | ||
|
||
"github.com/cr-mao/lori/log" | ||
"github.com/cr-mao/lori/transport" | ||
) | ||
|
||
var _ transport.Server = &pprof{} | ||
|
||
type pprof struct { | ||
addr string | ||
} | ||
|
||
func NewPProf(addr string) *pprof { | ||
return &pprof{ | ||
addr: addr, | ||
} | ||
} | ||
|
||
func (p *pprof) Name() string { | ||
return "pprof" | ||
} | ||
|
||
func (p *pprof) Start(_ context.Context) error { | ||
log.Debug("pprof addr:", p.addr) | ||
fmt.Println("pprof addr:", p.addr) | ||
err := http.ListenAndServe(p.addr, nil) | ||
if err != nil { | ||
log.Errorf("pprof server start failed: %v", err) | ||
} | ||
return err | ||
} | ||
|
||
func (p *pprof) Stop(ctx context.Context) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters