aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/flags.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-04-21 00:17:04 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-04-21 00:17:04 +0800
commit3d7c1b8194e509f61fb64a129242b3170ecffd08 (patch)
treed31d4bc0d7bd95149d237250cd88a9f86778c504 /cmd/utils/flags.go
parentf28b2bb6edad287ae418abc7b9ef5e147df84886 (diff)
parent3b008723db3f89696dab53b311cbd2efc987a01f (diff)
downloadgo-tangerine-3d7c1b8194e509f61fb64a129242b3170ecffd08.tar.gz
go-tangerine-3d7c1b8194e509f61fb64a129242b3170ecffd08.tar.zst
go-tangerine-3d7c1b8194e509f61fb64a129242b3170ecffd08.zip
Merge pull request #755 from karalabe/command-flags-cleanup
cmd/geth, cmd/utils: add cli flags for pprof and whisper
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r--cmd/utils/flags.go53
1 files changed, 38 insertions, 15 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index f70f4243e..b8f3982e2 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"
@@ -140,10 +143,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(),
+ }
+ PProfEanbledFlag = cli.BoolFlag{
+ Name: "pprof",
+ Usage: "Whether the profiling server should be enabled",
+ }
+ PProfPortFlag = cli.IntFlag{
+ Name: "pprofport",
+ Usage: "Port on which the profiler should listen",
+ Value: 6060,
+ }
// RPC settings
RPCEnabledFlag = cli.BoolFlag{
@@ -194,25 +220,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 {
@@ -274,7 +290,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
NAT: GetNAT(ctx),
NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name),
NodeKey: GetNodeKey(ctx),
- Shh: true,
+ Shh: ctx.GlobalBool(WhisperEnabledFlag.Name),
Dial: true,
BootNodes: ctx.GlobalString(BootnodesFlag.Name),
}
@@ -324,3 +340,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))
+ }()
+}