diff options
author | Felix Lange <fjl@twurst.com> | 2016-01-26 21:39:21 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-01-28 20:36:11 +0800 |
commit | 3750d835a1697f6784c727074cc959dda33cdcf3 (patch) | |
tree | 6183747f1ce69b6bb1ed256e4dd9a1bba0031d69 /cmd/geth/main.go | |
parent | e287b56b69cdf8340f679e9cfd229c959cc45e24 (diff) | |
download | dexon-3750d835a1697f6784c727074cc959dda33cdcf3.tar.gz dexon-3750d835a1697f6784c727074cc959dda33cdcf3.tar.zst dexon-3750d835a1697f6784c727074cc959dda33cdcf3.zip |
internal/debug: APIs for profiling and tracing
The debug package provides an RPC wrapper for glog settings and the
debugging facilities of the Go runtime. They can be triggered through
both command line flags and the IPC listener.
Diffstat (limited to 'cmd/geth/main.go')
-rw-r--r-- | cmd/geth/main.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index e6d190914..09c7eee05 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -20,7 +20,6 @@ package main import ( "fmt" "io/ioutil" - _ "net/http/pprof" "os" "path/filepath" "runtime" @@ -34,6 +33,7 @@ import ( "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/internal/debug" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/metrics" @@ -326,12 +326,6 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.VMEnableJitFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, - utils.VerbosityFlag, - utils.BacktraceAtFlag, - utils.LogVModuleFlag, - utils.LogFileFlag, - utils.PProfEanbledFlag, - utils.PProfPortFlag, utils.MetricsEnabledFlag, utils.SolcPathFlag, utils.GpoMinGasPriceFlag, @@ -342,23 +336,29 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.GpobaseCorrectionFactorFlag, utils.ExtraDataFlag, } + app.Flags = append(app.Flags, debug.Flags...) + app.Before = func(ctx *cli.Context) error { runtime.GOMAXPROCS(runtime.NumCPU()) + if err := debug.Setup(ctx); err != nil { + return err + } + // Start system runtime metrics collection + go metrics.CollectProcessMetrics(3 * time.Second) - utils.SetupLogger(ctx) utils.SetupNetwork(ctx) utils.SetupVM(ctx) - if ctx.GlobalBool(utils.PProfEanbledFlag.Name) { - utils.StartPProf(ctx) - } return nil } - // Start system runtime metrics collection - go metrics.CollectProcessMetrics(3 * time.Second) + + app.After = func(ctx *cli.Context) error { + logger.Flush() + debug.Exit() + return nil + } } func main() { - defer logger.Flush() if err := app.Run(os.Args); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) |