feat(cmd): enable pprof configuration for signle-node deployment #22779997

Signed-off-by: zhumingze <zhumingze@oppo.com>
This commit is contained in:
zhumingze 2024-11-14 19:33:26 +08:00 committed by AmazingChi
parent 0a7b6fda95
commit 18ae97d850
3 changed files with 12 additions and 1 deletions

View File

@ -52,6 +52,8 @@ import (
const (
ConfigKeyRole = "role"
ConfigKeyLocalIp = "localIP"
ConfigKeyBindIp = "bindIp"
ConfigKeyLogDir = "logDir"
ConfigKeyLogLevel = "logLevel"
ConfigKeyLogRotateSize = "logRotateSize"
@ -173,6 +175,8 @@ func main() {
*/
role := cfg.GetString(ConfigKeyRole)
bindIp := cfg.GetBool(ConfigKeyBindIp)
localIp := cfg.GetString(ConfigKeyLocalIp)
logDir := cfg.GetString(ConfigKeyLogDir)
logLevel := cfg.GetString(ConfigKeyLogLevel)
logRotateSize := cfg.GetInt64(ConfigKeyLogRotateSize)
@ -343,7 +347,12 @@ func main() {
}
})
mainMux.Handle("/", mainHandler)
e := http.ListenAndServe(fmt.Sprintf(":%v", profPort), mainMux)
addr := fmt.Sprintf(":%v", profPort)
if bindIp {
addr = fmt.Sprintf("%v:%v", localIp, profPort)
}
e := http.ListenAndServe(fmt.Sprintf("%v", addr), mainMux)
if e != nil {
log.LogFlush()
err = errors.NewErrorf("cannot listen pprof %v err %v", profPort, e)

View File

@ -2,6 +2,7 @@
"role": "datanode",
"listen": "17310",
"localIP": "_ip_",
"prof": "17320",
"bindIp": "true",
"raftHeartbeat": "17330",
"raftReplica": "17340",

View File

@ -2,6 +2,7 @@
"role": "metanode",
"listen": "17210",
"localIP": "_ip_",
"prof": "17220",
"bindIp": "true",
"raftHeartbeatPort": "17230",
"raftReplicaPort": "17240",