@@ -150,6 +150,7 @@ func createDotConfig(ctx *cli.Context) (*dot.Config, error) {
150150 setDotCoreConfig (ctx , tomlCfg .Core , & cfg .Core )
151151 setDotNetworkConfig (ctx , tomlCfg .Network , & cfg .Network )
152152 setDotRPCConfig (ctx , tomlCfg .RPC , & cfg .RPC )
153+ setDotPprofConfig (ctx , tomlCfg .Pprof , & cfg .Pprof )
153154
154155 if rewind := ctx .GlobalInt (RewindFlag .Name ); rewind != 0 {
155156 cfg .State .Rewind = rewind
@@ -872,3 +873,49 @@ func updateDotConfigFromGenesisData(ctx *cli.Context, cfg *dot.Config) error {
872873
873874 return nil
874875}
876+
877+ func setDotPprofConfig (ctx * cli.Context , tomlCfg ctoml.PprofConfig , cfg * dot.PprofConfig ) {
878+ if ! cfg .Enabled {
879+ // only allow to enable pprof from the TOML configuration.
880+ // If it is enabled by default, it cannot be disabled.
881+ cfg .Enabled = tomlCfg .Enabled
882+ }
883+
884+ if tomlCfg .ListeningAddress != "" {
885+ cfg .Settings .ListeningAddress = tomlCfg .ListeningAddress
886+ }
887+
888+ if tomlCfg .BlockRate > 0 {
889+ // block rate must be 0 (disabled) by default, since we
890+ // cannot disable it here.
891+ cfg .Settings .BlockProfileRate = tomlCfg .BlockRate
892+ }
893+
894+ if tomlCfg .MutexRate > 0 {
895+ // mutex rate must be 0 (disabled) by default, since we
896+ // cannot disable it here.
897+ cfg .Settings .MutexProfileRate = tomlCfg .MutexRate
898+ }
899+
900+ // check --pprofserver flag and update node configuration
901+ if enabled := ctx .GlobalBool (PprofServerFlag .Name ); enabled || cfg .Enabled {
902+ cfg .Enabled = true
903+ } else if ctx .IsSet (PprofServerFlag .Name ) && ! enabled {
904+ cfg .Enabled = false
905+ }
906+
907+ // check --pprofaddress flag and update node configuration
908+ if address := ctx .GlobalString (PprofAddressFlag .Name ); address != "" {
909+ cfg .Settings .ListeningAddress = address
910+ }
911+
912+ if rate := ctx .GlobalInt (PprofBlockRateFlag .Name ); rate > 0 {
913+ cfg .Settings .BlockProfileRate = rate
914+ }
915+
916+ if rate := ctx .GlobalInt (PprofMutexRateFlag .Name ); rate > 0 {
917+ cfg .Settings .MutexProfileRate = rate
918+ }
919+
920+ logger .Debug ("pprof configuration: " + cfg .String ())
921+ }
0 commit comments