支持配置启动PPROF

This commit is contained in:
2021-04-19 00:03:25 +08:00
parent 844da3f325
commit d2a6f851f8
5 changed files with 41 additions and 13 deletions

View File

@ -41,6 +41,8 @@ const (
DefaultLogSplitInterval = logger.TimeIntervalTypeHour
// DefaultStoreConnection 默认存储连接
DefaultStoreConnection = true
// DefaultEnablePprof 默认关闭pprof
DefaultEnablePprof = false
)
// WSServerConfig WS-Server的配置
@ -58,6 +60,8 @@ type WSServerConfig struct {
LogSplitInterval logger.TimeIntervalType // 日至切割的时间间隔
StoreConnection bool // 存储连接
ConnectionManager storage.IConnection // 连接管理实例
EnablePprof bool // 开启pprof, 默认关闭
PprofPort int // pprof监听的端口
}
// SetWSServerConfig 设置WS-Server的配置
@ -94,6 +98,18 @@ func SetWSServerLogEnable(logPath string, logFile string, logLevel zapcore.Level
}
}
// EnablePprof 开启PProf,由于多模块共享一个进程,任意一个模块开启,就认为是开启
//
// Author : go_developer@163.com<张德满>
//
// Date : 11:24 下午 2021/4/18
func EnablePprof(pprofPort int) SetWSServerConfig {
return func(wsc *WSServerConfig) {
wsc.EnablePprof = true
wsc.PprofPort = pprofPort
}
}
// DisableStoreConnection 禁用连接存储
//
// Author : go_developer@163.com<张德满>