mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-20 19:40:52 +00:00
add ^C handler to LC binary (#4337)
Avoid ugly error message on ^C by adding a minimal ^C hook.
This commit is contained in:
parent
84bacf7cc6
commit
774eede63b
@ -20,7 +20,24 @@ from ./consensus_object_pools/consensus_manager import runForkchoiceUpdated
|
|||||||
from ./gossip_processing/block_processor import newExecutionPayload
|
from ./gossip_processing/block_processor import newExecutionPayload
|
||||||
from ./gossip_processing/eth2_processor import toValidationResult
|
from ./gossip_processing/eth2_processor import toValidationResult
|
||||||
|
|
||||||
|
# this needs to be global, so it can be set in the Ctrl+C signal handler
|
||||||
|
var globalRunning = true
|
||||||
|
|
||||||
programMain:
|
programMain:
|
||||||
|
## Ctrl+C handling
|
||||||
|
proc controlCHandler() {.noconv.} =
|
||||||
|
when defined(windows):
|
||||||
|
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
||||||
|
try:
|
||||||
|
setupForeignThreadGc()
|
||||||
|
except Exception as exc: raiseAssert exc.msg # shouldn't happen
|
||||||
|
notice "Shutting down after having received SIGINT"
|
||||||
|
globalRunning = false
|
||||||
|
try:
|
||||||
|
setControlCHook(controlCHandler)
|
||||||
|
except Exception as exc: # TODO Exception
|
||||||
|
warn "Cannot set ctrl-c handler", msg = exc.msg
|
||||||
|
|
||||||
var config = makeBannerAndConfig(
|
var config = makeBannerAndConfig(
|
||||||
"Nimbus light client " & fullVersionStr, LightClientConf)
|
"Nimbus light client " & fullVersionStr, LightClientConf)
|
||||||
setupLogging(config.logLevel, config.logStdout, config.logFile)
|
setupLogging(config.logLevel, config.logStdout, config.logFile)
|
||||||
@ -235,5 +252,7 @@ programMain:
|
|||||||
lightClient.start()
|
lightClient.start()
|
||||||
|
|
||||||
asyncSpawn runOnSecondLoop()
|
asyncSpawn runOnSecondLoop()
|
||||||
while true:
|
while globalRunning:
|
||||||
poll()
|
poll()
|
||||||
|
|
||||||
|
notice "Exiting light client"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user