Skip to content

Instantly share code, notes, and snippets.

@hilkeheremans
Created April 29, 2016 19:29
Show Gist options
  • Save hilkeheremans/0b8a67a908fa203cac4ae9ff50fb86e8 to your computer and use it in GitHub Desktop.
Save hilkeheremans/0b8a67a908fa203cac4ae9ff50fb86e8 to your computer and use it in GitHub Desktop.
Nodejs and Docker: proper exits
// add to index.js
exitOnSignal('SIGINT');
exitOnSignal('SIGTERM');
function exitOnSignal(signal) {
process.on(signal, function() {
console.log('\ncaught ' + signal + ', exiting');
// perform all required cleanup
process.exit(1);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment