diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-04-20 23:45:37 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-04-20 23:45:37 +0800 |
commit | 8830403acfea745bd5e256d1498727e9128f02ae (patch) | |
tree | 976ba0d64a1b820de16f9445773fadfe1dee0e00 /cmd/utils/flags.go | |
parent | 76025cc4245f0abc0749f4d1e433be865107bf24 (diff) | |
download | go-tangerine-8830403acfea745bd5e256d1498727e9128f02ae.tar go-tangerine-8830403acfea745bd5e256d1498727e9128f02ae.tar.gz go-tangerine-8830403acfea745bd5e256d1498727e9128f02ae.tar.bz2 go-tangerine-8830403acfea745bd5e256d1498727e9128f02ae.tar.lz go-tangerine-8830403acfea745bd5e256d1498727e9128f02ae.tar.xz go-tangerine-8830403acfea745bd5e256d1498727e9128f02ae.tar.zst go-tangerine-8830403acfea745bd5e256d1498727e9128f02ae.zip |
cmd/geth, cmd/utils: add cli flags for pprof and whisper.
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r-- | cmd/utils/flags.go | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a1d9eedda..3b1fda32e 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -2,6 +2,9 @@ package utils import ( "crypto/ecdsa" + "fmt" + "log" + "net/http" "os" "path" "runtime" @@ -136,10 +139,33 @@ var ( Usage: "Send json structured log output to a file or '-' for standard output (default: no json output)", Value: "", } + LogToStdErrFlag = cli.BoolFlag{ + Name: "logtostderr", + Usage: "Logs are written to standard error instead of to files.", + } + LogVModuleFlag = cli.GenericFlag{ + Name: "vmodule", + Usage: "The syntax of the argument is a comma-separated list of pattern=N, where pattern is a literal file name (minus the \".go\" suffix) or \"glob\" pattern and N is a V level.", + Value: glog.GetVModule(), + } VMDebugFlag = cli.BoolFlag{ Name: "vmdebug", Usage: "Virtual Machine debug output", } + BacktraceAtFlag = cli.GenericFlag{ + Name: "backtrace_at", + Usage: "When set to a file and line number holding a logging statement a stack trace will be written to the Info log", + Value: glog.GetTraceLocation(), + } + PProfEnabledFlag = cli.BoolFlag{ + Name: "pprof", + Usage: "Whether the profiling server is enabled", + } + PProfPortFlag = cli.IntFlag{ + Name: "pprofport", + Usage: "Port on which the profiler should listen", + Value: 6060, + } // RPC settings RPCEnabledFlag = cli.BoolFlag{ @@ -190,25 +216,15 @@ var ( Usage: "Port mapping mechanism (any|none|upnp|pmp|extip:<IP>)", Value: "any", } + WhisperEnabledFlag = cli.BoolFlag{ + Name: "shh", + Usage: "Whether the whisper sub-protocol is enabled", + } JSpathFlag = cli.StringFlag{ Name: "jspath", Usage: "JS library path to be used with console and js subcommands", Value: ".", } - BacktraceAtFlag = cli.GenericFlag{ - Name: "backtrace_at", - Usage: "When set to a file and line number holding a logging statement a stack trace will be written to the Info log", - Value: glog.GetTraceLocation(), - } - LogToStdErrFlag = cli.BoolFlag{ - Name: "logtostderr", - Usage: "Logs are written to standard error instead of to files.", - } - LogVModuleFlag = cli.GenericFlag{ - Name: "vmodule", - Usage: "The syntax of the argument is a comma-separated list of pattern=N, where pattern is a literal file name (minus the \".go\" suffix) or \"glob\" pattern and N is a V level.", - Value: glog.GetVModule(), - } ) func GetNAT(ctx *cli.Context) nat.Interface { @@ -269,7 +285,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { Port: ctx.GlobalString(ListenPortFlag.Name), NAT: GetNAT(ctx), NodeKey: GetNodeKey(ctx), - Shh: true, + Shh: ctx.GlobalBool(WhisperEnabledFlag.Name), Dial: true, BootNodes: ctx.GlobalString(BootnodesFlag.Name), } @@ -319,3 +335,10 @@ func StartRPC(eth *eth.Ethereum, ctx *cli.Context) { xeth := xeth.New(eth, nil) _ = rpc.Start(xeth, config) } + +func StartPProf(ctx *cli.Context) { + address := fmt.Sprintf("localhost:%d", ctx.GlobalInt(PProfPortFlag.Name)) + go func() { + log.Println(http.ListenAndServe(address, nil)) + }() +} |