chore(wakunode): handle sigsegv signal (#1430)

This commit is contained in:
Alvaro Revuelta 2022-11-29 16:02:18 +01:00 committed by GitHub
parent bcab36902d
commit 34d116ff58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 2 deletions

View File

@ -691,7 +691,7 @@ when isMainModule:
when defined(windows):
# workaround for https://github.com/nim-lang/Nim/issues/4057
setupForeignThreadGc()
info "Shutting down after receiving SIGINT"
notice "Shutting down after receiving SIGINT"
waitFor node.stop()
quit(QuitSuccess)
@ -700,12 +700,25 @@ when isMainModule:
# Handle SIGTERM
when defined(posix):
proc handleSigterm(signal: cint) {.noconv.} =
info "Shutting down after receiving SIGTERM"
notice "Shutting down after receiving SIGTERM"
waitFor node.stop()
quit(QuitSuccess)
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"
runForever()