Skip to content

Commit

Permalink
Process must exit when receiving SIGTERM
Browse files Browse the repository at this point in the history
When a process is stopped using a signal (usually SIGTERM),
it should be stopped using process.exit() function.
  • Loading branch information
humaite authored and VinceJuliano committed Feb 4, 2025
1 parent 32315db commit 398d483
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions servers/mu/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ export const server = pipe(
})

process.on('SIGTERM', () => {
logger({ log: 'Recevied SIGTERM. Gracefully shutting down server...' })
server.close(() => logger({ log: 'Server Shut Down' }))
logger({ log: 'Received SIGTERM. Gracefully shutting down server...' })
server.close(() => {
logger({ log: 'Server Shut Down' })
process.exit()
})
})

domain.apis.initCronProcs().then(() => {
Expand Down
7 changes: 5 additions & 2 deletions servers/ur/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ pipe(
})

process.on('SIGTERM', () => {
logger('Recevied SIGTERM. Gracefully shutting down server...')
server.close(() => logger('Server Shut Down'))
logger('Received SIGTERM. Gracefully shutting down server...')
server.close(() => {
logger('Server Shut Down')
process.exit()
})
})

return server
Expand Down

0 comments on commit 398d483

Please sign in to comment.