Created
April 29, 2016 19:29
-
-
Save hilkeheremans/0b8a67a908fa203cac4ae9ff50fb86e8 to your computer and use it in GitHub Desktop.
Nodejs and Docker: proper exits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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