mirror of https://github.com/waku-org/nwaku.git
Fix Ctrl-C quitting (#1416)
This commit is contained in:
parent
b77a4faa55
commit
4b180c89bd
|
@ -687,14 +687,17 @@ when isMainModule:
|
|||
## Setup shutdown hooks for this process.
|
||||
## Stop node gracefully on shutdown.
|
||||
|
||||
proc asyncStopper(node: WakuNode) {.async.} =
|
||||
await node.stop()
|
||||
quit(QuitSuccess)
|
||||
|
||||
# Handle Ctrl-C SIGINT
|
||||
proc handleCtrlC() {.noconv.} =
|
||||
when defined(windows):
|
||||
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
||||
setupForeignThreadGc()
|
||||
notice "Shutting down after receiving SIGINT"
|
||||
waitFor node.stop()
|
||||
quit(QuitSuccess)
|
||||
asyncSpawn asyncStopper(node)
|
||||
|
||||
setControlCHook(handleCtrlC)
|
||||
|
||||
|
@ -702,8 +705,7 @@ when isMainModule:
|
|||
when defined(posix):
|
||||
proc handleSigterm(signal: cint) {.noconv.} =
|
||||
notice "Shutting down after receiving SIGTERM"
|
||||
waitFor node.stop()
|
||||
quit(QuitSuccess)
|
||||
asyncSpawn asyncStopper(node)
|
||||
|
||||
c_signal(ansi_c.SIGTERM, handleSigterm)
|
||||
|
||||
|
|
Loading…
Reference in New Issue