mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
feat: modular pprof server
This module is about 384KiB in windows/amd64
This commit is contained in:
parent
e4bd30d000
commit
fcc9962b15
9
main.go
9
main.go
@ -18,16 +18,17 @@ import (
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
"golang.org/x/term"
|
||||
|
||||
_ "github.com/Mrs4s/go-cqhttp/modules/mime" // mime检查模块
|
||||
"github.com/Mrs4s/go-cqhttp/modules/servers"
|
||||
_ "github.com/Mrs4s/go-cqhttp/modules/silk" // silk编码模块
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/coolq"
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
"github.com/Mrs4s/go-cqhttp/global/terminal"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
"github.com/Mrs4s/go-cqhttp/internal/selfupdate"
|
||||
"github.com/Mrs4s/go-cqhttp/modules/servers"
|
||||
"github.com/Mrs4s/go-cqhttp/server"
|
||||
|
||||
_ "github.com/Mrs4s/go-cqhttp/modules/mime" // mime检查模块
|
||||
_ "github.com/Mrs4s/go-cqhttp/modules/pprof" // pprof 性能分析
|
||||
_ "github.com/Mrs4s/go-cqhttp/modules/silk" // silk编码模块
|
||||
)
|
||||
|
||||
// 允许通过配置文件设置的状态列表
|
||||
|
@ -1,4 +1,4 @@
|
||||
package server
|
||||
package pprof
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/coolq"
|
||||
"github.com/Mrs4s/go-cqhttp/modules/config"
|
||||
"github.com/Mrs4s/go-cqhttp/modules/servers"
|
||||
)
|
||||
|
||||
// runPprof 启动 pprof 性能分析服务器
|
||||
@ -33,7 +34,6 @@ func runPprof(_ *coolq.CQBot, node yaml.Node) {
|
||||
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
server := http.Server{Addr: addr, Handler: mux}
|
||||
go func() {
|
||||
log.Infof("pprof debug 服务器已启动: %v/debug/pprof", addr)
|
||||
log.Warnf("警告: pprof 服务不支持鉴权, 请不要运行在公网.")
|
||||
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
@ -43,5 +43,8 @@ func runPprof(_ *coolq.CQBot, node yaml.Node) {
|
||||
time.Sleep(time.Second * 5)
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func init() {
|
||||
servers.Register("pprof", runPprof)
|
||||
}
|
@ -8,6 +8,5 @@ func init() {
|
||||
servers.Register("http", runHTTP)
|
||||
servers.Register("ws", runWSServer)
|
||||
servers.Register("ws-reverse", runWSClient)
|
||||
servers.Register("pprof", runPprof)
|
||||
servers.Register("lambda", runLambda)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user