Skip to content

Instantly share code, notes, and snippets.

@markdaws
Created August 11, 2011 22:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markdaws/1140933 to your computer and use it in GitHub Desktop.
Save markdaws/1140933 to your computer and use it in GitHub Desktop.
Shutting down node.js and flushing stdout and stderr
function flushAndShutdown(exitCode) {
if(process.stdout.flush()) {
process.exit(exitCode);
}
else {
process.stdout.on('drain', function() {
process.exit(exitCode);
})
}
}
@Offirmo
Copy link

Offirmo commented Sep 12, 2014

as of today (node 0.10.31), streams no longer have flush()...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment