commented ctrl+c handler

This commit is contained in:
Pedro Miranda 2025-01-17 15:59:18 +00:00
parent 633c04443b
commit 0fe437f4e4

View File

@ -2398,26 +2398,26 @@ proc doRunBeaconNode*(config: var BeaconNodeConf, rng: ref HmacDrbgContext) {.ra
for node in metadata.bootstrapNodes:
config.bootstrapNodes.add node
## 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"
bnStatus = BeaconNodeStatus.Stopping
try:
setControlCHook(controlCHandler)
except Exception as exc: # TODO Exception
warn "Cannot set ctrl-c handler", msg = exc.msg
# ## 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"
# bnStatus = BeaconNodeStatus.Stopping
# try:
# setControlCHook(controlCHandler)
# except Exception as exc: # TODO Exception
# warn "Cannot set ctrl-c handler", msg = exc.msg
# equivalent SIGTERM handler
when defined(posix):
proc SIGTERMHandler(signal: cint) {.noconv.} =
notice "Shutting down after having received SIGTERM"
bnStatus = BeaconNodeStatus.Stopping
c_signal(ansi_c.SIGTERM, SIGTERMHandler)
# # equivalent SIGTERM handler
# when defined(posix):
# proc SIGTERMHandler(signal: cint) {.noconv.} =
# notice "Shutting down after having received SIGTERM"
# bnStatus = BeaconNodeStatus.Stopping
# c_signal(ansi_c.SIGTERM, SIGTERMHandler)
block:
let res =