Skip to content

Instantly share code, notes, and snippets.

@stolsma
Created September 20, 2011 14:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stolsma/1229295 to your computer and use it in GitHub Desktop.
Save stolsma/1229295 to your computer and use it in GitHub Desktop.
Downgrade process after connecting to port 80
app.listen(process.env.NODE_ENV === 'production' ? 80 : 8000, function() {
console.log('Ready');
// if run as root, downgrade to the owner of this file
if (process.getuid() === 0)
require('fs').stat(__filename, function(err, stats) {
if (err) return console.log(err)
process.setuid(stats.uid);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment