close-with-grace
Version:
Exit your process, gracefully (if possible)
17 lines (12 loc) • 462 B
JavaScript
const closeWithGrace = require('..')
// Handle skipped events to prevent crashes
process.on('unhandledRejection', () => {})
process.on('uncaughtException', () => {})
process.on('SIGTERM', () => {})
closeWithGrace({ skip: ['unhandledRejection', 'uncaughtException', 'SIGTERM'], delay: 500 }, async function ({ signal, err }) {
console.log('callback called')
})
// to keep the process open
setInterval(() => {}, 1000)
console.error(process.pid)