Skip to content

Instantly share code, notes, and snippets.

@HenriqueSilverio
Created January 28, 2021 13:38
Show Gist options
  • Save HenriqueSilverio/428f7e71e2e4f2332a4b67a8949bff68 to your computer and use it in GitHub Desktop.
Save HenriqueSilverio/428f7e71e2e4f2332a4b67a8949bff68 to your computer and use it in GitHub Desktop.
const cleanup = async () => {
try {
console.log('Cleaning up')
} catch (error) {
console.error(error)
process.exit(1)
}
}
const start = async () => {
console.log('Starting')
}
process.on('uncaughtException', cleanup)
process.on('unhandledRejection', cleanup)
process.on('SIGTERM', cleanup)
process.on('SIGINT', cleanup)
start()
.catch(cleanup)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment