Skip to content

Instantly share code, notes, and snippets.

@fvdm
Last active September 14, 2018 12:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fvdm/ca2716b40ff4d98acad4 to your computer and use it in GitHub Desktop.
Save fvdm/ca2716b40ff4d98acad4 to your computer and use it in GitHub Desktop.
// Add pre-exit script
process.on ('exit', code => {
console.log (`Whoa! Exit code ${code}, cleaning up...`);
// i.e. close database
});
// Add another for fun
process.on ('exit', code => {
if (code > 0) {
console.log ('Hmm something went wrong');
} else {
console.log ('And done!');
}
});
console.log ('App ready.');
console.log ('Doing app stuff...');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment