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

View File

@ -146,6 +146,7 @@ proc start() =
nimbus.rpcServer.start()
# metrics server
when defined(insecure):
if conf.net.metricsServer:
let metricsAddress = "127.0.0.1"
info "Starting metrics HTTP server", address = metricsAddress, port = conf.net.metricsServerPort

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