mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/geth: read metrics from config file if given
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
459d46b26a
commit
641df0e39b
4 changed files with 13 additions and 14 deletions
|
|
@ -145,7 +145,7 @@ func loadBaseConfig(ctx *cli.Context) gethConfig {
|
|||
}
|
||||
|
||||
// makeConfigNode loads geth configuration and creates a blank node instance.
|
||||
func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
|
||||
func makeConfigNode(ctx *cli.Context) (*node.Node, *gethConfig) {
|
||||
cfg := loadBaseConfig(ctx)
|
||||
stack, err := node.New(&cfg.Node)
|
||||
if err != nil {
|
||||
|
|
@ -162,12 +162,11 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
|
|||
}
|
||||
applyMetricConfig(ctx, &cfg)
|
||||
|
||||
return stack, cfg
|
||||
return stack, &cfg
|
||||
}
|
||||
|
||||
// makeFullNode loads geth configuration and creates the Ethereum backend.
|
||||
func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
|
||||
stack, cfg := makeConfigNode(ctx)
|
||||
func makeFullNode(ctx *cli.Context, stack *node.Node, cfg *gethConfig) ethapi.Backend {
|
||||
if ctx.IsSet(utils.OverrideCancun.Name) {
|
||||
v := ctx.Uint64(utils.OverrideCancun.Name)
|
||||
cfg.Eth.OverrideCancun = &v
|
||||
|
|
@ -225,7 +224,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
|
|||
utils.Fatalf("failed to register catalyst service: %v", err)
|
||||
}
|
||||
}
|
||||
return stack, backend
|
||||
return backend
|
||||
}
|
||||
|
||||
// dumpConfig is the dumpconfig command.
|
||||
|
|
|
|||
|
|
@ -70,7 +70,9 @@ JavaScript API. See https://geth.ethereum.org/docs/interacting-with-geth/javascr
|
|||
func localConsole(ctx *cli.Context) error {
|
||||
// Create and start the node based on the CLI flags
|
||||
prepare(ctx)
|
||||
stack, backend := makeFullNode(ctx)
|
||||
stack, cfg := makeConfigNode(ctx)
|
||||
utils.SetupMetricsFromConfig(&cfg.Metrics)
|
||||
backend := makeFullNode(ctx, stack, cfg)
|
||||
startNode(ctx, stack, backend, true)
|
||||
defer stack.Close()
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||
"github.com/ethereum/go-ethereum/internal/flags"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"go.uber.org/automaxprocs/maxprocs"
|
||||
|
||||
|
|
@ -316,12 +315,6 @@ func prepare(ctx *cli.Context) {
|
|||
log.Info("Dropping default light client cache", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 128)
|
||||
ctx.Set(utils.CacheFlag.Name, strconv.Itoa(128))
|
||||
}
|
||||
|
||||
// Start metrics export if enabled
|
||||
utils.SetupMetrics(ctx)
|
||||
|
||||
// Start system runtime metrics collection
|
||||
go metrics.CollectProcessMetrics(3 * time.Second)
|
||||
}
|
||||
|
||||
// geth is the main entry point into the system if no special subcommand is run.
|
||||
|
|
@ -333,7 +326,9 @@ func geth(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
prepare(ctx)
|
||||
stack, backend := makeFullNode(ctx)
|
||||
stack, cfg := makeConfigNode(ctx)
|
||||
utils.SetupMetricsFromConfig(&cfg.Metrics)
|
||||
backend := makeFullNode(ctx, stack, cfg)
|
||||
defer stack.Close()
|
||||
|
||||
startNode(ctx, stack, backend, false)
|
||||
|
|
|
|||
|
|
@ -2081,6 +2081,9 @@ func SetupMetricsFromConfig(c *metrics.Config) {
|
|||
} else if c.Port != 0 {
|
||||
log.Warn("influxdb.port specified without inflxdb.addr, metrics server will not start.")
|
||||
}
|
||||
|
||||
// Start system runtime metrics collection
|
||||
go metrics.CollectProcessMetrics(3 * time.Second)
|
||||
}
|
||||
|
||||
func SplitTagsFlag(tagsFlag string) map[string]string {
|
||||
|
|
|
|||
Loading…
Reference in a new issue