var debug = require('debug')('instant:util')
var posix = require('posix')

var MAX_SOCKETS = 10000

exports.downgradeUid = function () {
  if (process.platform === 'linux' && process.env.NODE_ENV === 'production') {
    process.setuid('www-data')
    debug('downgraded uid to ' + process.getuid())
  }
}

exports.upgradeLimits = function () {
  posix.setrlimit('nofile', { soft: MAX_SOCKETS, hard: MAX_SOCKETS })
  var limits = posix.getrlimit('nofile')
  debug('upgraded resource limits to ' + limits.soft)
}

@@ -209,16 +209,47 @@
 ion') %7B%0A
+    process.setgid('www-data')%0A
     proc
@@ -297,15 +297,44 @@
 ded 
-uid to 
+gid (' + process.getgid() + ') uid (
 ' + 
@@ -349,16 +349,22 @@
 getuid()
+ + ')'
 )%0A  %7D%0A%7D%0A

downgrade gid