fix rpc and websocket server config if they share the same port with engine api

also fixes json-rpc-engine-api server and websocket-engine-api server shutdown code,
checking if they actually created or not at startup.

fix #1119
This commit is contained in:
jangko 2022-06-13 17:20:12 +07:00
parent b23789d107
commit a37f8b17e2
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
3 changed files with 9 additions and 3 deletions

View File

@ -678,6 +678,10 @@ proc makeConfig*(cmdLine = commandLineParams()): NimbusConf =
# if udpPort not set in cli, then # if udpPort not set in cli, then
result.udpPort = result.tcpPort result.udpPort = result.tcpPort
# enable rpc server or ws server if they share common port with engine api
result.rpcEnabled = result.engineApiEnabled and (result.engineApiPort == result.rpcPort)
result.wsEnabled = result.engineApiWsEnabled and (result.engineApiWsPort == result.wsPort)
when isMainModule: when isMainModule:
# for testing purpose # for testing purpose
discard makeConfig() discard makeConfig()

View File

@ -335,11 +335,13 @@ proc stop*(nimbus: NimbusNode, conf: NimbusConf) {.async, gcsafe.} =
trace "Graceful shutdown" trace "Graceful shutdown"
if conf.rpcEnabled: if conf.rpcEnabled:
await nimbus.rpcServer.stop() await nimbus.rpcServer.stop()
if conf.engineApiEnabled: # nimbus.engineApiServer can be nil if conf.engineApiPort == conf.rpcPort
if conf.engineApiEnabled and nimbus.engineApiServer.isNil.not:
await nimbus.engineApiServer.stop() await nimbus.engineApiServer.stop()
if conf.wsEnabled: if conf.wsEnabled:
nimbus.wsRpcServer.stop() nimbus.wsRpcServer.stop()
if conf.engineApiWsEnabled: # nimbus.engineApiWsServer can be nil if conf.engineApiWsPort == conf.wsPort
if conf.engineApiWsEnabled and nimbus.engineApiWsServer.isNil.not:
nimbus.engineApiWsServer.stop() nimbus.engineApiWsServer.stop()
if conf.graphqlEnabled: if conf.graphqlEnabled:
await nimbus.graphqlServer.stop() await nimbus.graphqlServer.stop()

View File

@ -216,7 +216,7 @@ proc seen*(sn: Worker; bh: BlockHash; bn: BlockNumber) =
# ----------- # -----------
import import
../../../tests/replay/pp_light ../../../../tests/replay/pp_light
proc pp*(bh: BlockHash): string = proc pp*(bh: BlockHash): string =
bh.Hash256.pp bh.Hash256.pp