mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
Fix Ctrl-C quitting (#1416)
This commit is contained in:
parent
96e5316497
commit
ea92b36479
@ -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…
x
Reference in New Issue
Block a user