metrics: put the HTTP server under -d:insecure

- also fix an option parsing bug
- bump vendor/nim-eth and vendor/nim-metrics
This commit is contained in:
Ștefan Talpalaru 2019-07-18 00:50:16 +02:00 committed by zah
parent ed1b4d40f2
commit 409d771a50
4 changed files with 23 additions and 12 deletions

View File

@ -497,9 +497,9 @@ proc processNetArguments(key, value: string): ConfigStatus =
result = processInteger(value, res) result = processInteger(value, res)
if result == Success: if result == Success:
config.net.discPort = uint16(res and 0xFFFF) config.net.discPort = uint16(res and 0xFFFF)
elif skey == "metricsserver": elif skey == "metricsserver" and defined(insecure):
config.net.metricsServer = true config.net.metricsServer = true
elif skey == "metricsserverport": elif skey == "metricsserverport" and defined(insecure):
var res = 0 var res = 0
result = processInteger(value, res) result = processInteger(value, res)
if result == Success: if result == Success:
@ -602,6 +602,8 @@ proc processDebugArguments(key, value: string): ConfigStatus =
result = processInteger(value, res) result = processInteger(value, res)
if result == Success: if result == Success:
config.debug.logMetricsInterval = res config.debug.logMetricsInterval = res
else:
result = EmptyOption
proc dumpConfiguration*(): string = proc dumpConfiguration*(): string =
## Dumps current configuration as string ## Dumps current configuration as string
@ -680,6 +682,14 @@ proc getHelpString*(): string =
continue continue
logLevels.add($level) logLevels.add($level)
when defined(insecure):
let metricsServerHelp = """
--metricsServer Enable the metrics HTTP server
--metricsServerPort:<value> Metrics HTTP server port on localhost (default: 9093)"""
else:
let metricsServerHelp = ""
result = """ result = """
USAGE: USAGE:
@ -696,9 +706,7 @@ NETWORKING OPTIONS:
--bootnodesv5:<value> Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes) --bootnodesv5:<value> Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)
--staticnodes:<value> Comma separated enode URLs to connect with --staticnodes:<value> Comma separated enode URLs to connect with
--port:<value> Network listening TCP port (default: 30303) --port:<value> Network listening TCP port (default: 30303)
--discport:<value> Network listening UDP port (defaults to --port argument) --discport:<value> Network listening UDP port (defaults to --port argument)$7
--metricsServer Enable the metrics HTTP server
--metricsServerPort:<value> Metrics HTTP server port on localhost (default: 9093)
--maxpeers:<value> Maximum number of network peers (default: 25) --maxpeers:<value> Maximum number of network peers (default: 25)
--maxpendpeers:<value> Maximum number of pending connection attempts (default: 0) --maxpendpeers:<value> Maximum number of pending connection attempts (default: 0)
--nat:<value> NAT port mapping mechanism (any|none|upnp|pmp|<external IP>) (default: "any") --nat:<value> NAT port mapping mechanism (any|none|upnp|pmp|<external IP>) (default: "any")
@ -737,7 +745,8 @@ LOGGING AND DEBUGGING OPTIONS:
$defaultLogLevel, $defaultLogLevel,
strip($defaultProtocols, chars = {'{','}'}), strip($defaultProtocols, chars = {'{','}'}),
$defaultMaxMsgSize, $defaultMaxMsgSize,
$defaultMinPow $defaultMinPow,
metricsServerHelp,
] ]
proc processArguments*(msg: var string): ConfigStatus = proc processArguments*(msg: var string): ConfigStatus =
@ -783,6 +792,7 @@ proc processArguments*(msg: var string): ConfigStatus =
processArgument processDebugArguments, key, value, msg processArgument processDebugArguments, key, value, msg
if result != Success: if result != Success:
msg = "Unknown option: '" & key & "'." msg = "Unknown option: '" & key & "'."
break
of cmdEnd: of cmdEnd:
doAssert(false) # we're never getting this kind here doAssert(false) # we're never getting this kind here

View File

@ -146,10 +146,11 @@ proc start() =
nimbus.rpcServer.start() nimbus.rpcServer.start()
# metrics server # metrics server
if conf.net.metricsServer: when defined(insecure):
let metricsAddress = "127.0.0.1" if conf.net.metricsServer:
info "Starting metrics HTTP server", address = metricsAddress, port = conf.net.metricsServerPort let metricsAddress = "127.0.0.1"
metrics.startHttpServer(metricsAddress, Port(conf.net.metricsServerPort)) info "Starting metrics HTTP server", address = metricsAddress, port = conf.net.metricsServerPort
metrics.startHttpServer(metricsAddress, Port(conf.net.metricsServerPort))
# Connect directly to the static nodes # Connect directly to the static nodes
for enode in conf.net.staticNodes: for enode in conf.net.staticNodes:

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit 0a5ffaa8b35dacbb3992879667ea5ce37690b7dd Subproject commit e195868a64bb3b2a4381db3a030298bc1ec626eb

2
vendor/nim-metrics vendored

@ -1 +1 @@
Subproject commit dc98c44cdff1a23d5f364727854e875948eac158 Subproject commit 169c27df6ed899dbe28bb1b7751fb5f2d937c6d0