handle Exceptions on shutdown

This commit is contained in:
gmega 2024-05-09 19:15:20 -03:00
parent 556e71b11b
commit e3863a15d7
No known key found for this signature in database
GPG Key ID: FFD8DAF00660270F
1 changed files with 7 additions and 3 deletions

View File

@ -185,9 +185,13 @@ proc start*(s: CodexServer) {.async.} =
proc stop*(s: CodexServer) {.async.} =
notice "Stopping codex node"
s.taskpool.syncAll()
s.taskpool.shutdown()
try:
s.taskpool.syncAll()
s.taskpool.shutdown()
except Exception as exc:
# Log and swallow as we're shutting down.
error "Error shutting down taskpool. Attempting to shut " &
"down the remaining services anyway.", error = exc.msg
await allFuturesThrowing(
s.restServer.stop(),