mirror of https://github.com/waku-org/nwaku.git
chore(wakunode): handle sigsegv signal (#1430)
This commit is contained in:
parent
bcab36902d
commit
34d116ff58
|
@ -691,7 +691,7 @@ when isMainModule:
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
||||||
setupForeignThreadGc()
|
setupForeignThreadGc()
|
||||||
info "Shutting down after receiving SIGINT"
|
notice "Shutting down after receiving SIGINT"
|
||||||
waitFor node.stop()
|
waitFor node.stop()
|
||||||
quit(QuitSuccess)
|
quit(QuitSuccess)
|
||||||
|
|
||||||
|
@ -700,12 +700,25 @@ when isMainModule:
|
||||||
# Handle SIGTERM
|
# Handle SIGTERM
|
||||||
when defined(posix):
|
when defined(posix):
|
||||||
proc handleSigterm(signal: cint) {.noconv.} =
|
proc handleSigterm(signal: cint) {.noconv.} =
|
||||||
info "Shutting down after receiving SIGTERM"
|
notice "Shutting down after receiving SIGTERM"
|
||||||
waitFor node.stop()
|
waitFor node.stop()
|
||||||
quit(QuitSuccess)
|
quit(QuitSuccess)
|
||||||
|
|
||||||
c_signal(ansi_c.SIGTERM, handleSigterm)
|
c_signal(ansi_c.SIGTERM, handleSigterm)
|
||||||
|
|
||||||
|
# Handle SIGSEGV
|
||||||
|
when defined(posix):
|
||||||
|
proc handleSigsegv(signal: cint) {.noconv.} =
|
||||||
|
fatal "Shutting down after receiving SIGSEGV"
|
||||||
|
waitFor node.stop()
|
||||||
|
|
||||||
|
# Only available with --stacktrace:on --linetrace:on
|
||||||
|
writeStackTrace()
|
||||||
|
|
||||||
|
quit(QuitFailure)
|
||||||
|
|
||||||
|
c_signal(ansi_c.SIGSEGV, handleSigsegv)
|
||||||
|
|
||||||
info "Node setup complete"
|
info "Node setup complete"
|
||||||
|
|
||||||
runForever()
|
runForever()
|
||||||
|
|
Loading…
Reference in New Issue