Skip to content

Commit

Permalink
fix: time gap to stop server on SIGTERM (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
veckatimest authored Jun 19, 2024
1 parent 42c0a68 commit 38da647
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ process.on('uncaughtException', (error) => {
process.exit(1)
})

function handle (signal) {
async function handle (signal) {
emergencyLogger.error(`Received SIGNAL ${signal}, exiting`)

// we wait for it here, so that request that transfer data right now
// can finish it and not fail
await new Promise((resolve) => {
setTimeout(resolve, 1500)
})

server.close(async (error) => {
if (error) {
emergencyLogger.error(`Failed to gracefully shutdown server with error ${error.stack}`)
Expand Down

0 comments on commit 38da647

Please sign in to comment.