Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

bouncy dies on file descriptor error

View gist:06d3df6d4665f1f13582
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
var bouncy = require('bouncy'),
cp = require('child_process');
 
console.log('starting web sites');
 
var www = cp.spawn('node', ['./www/server.js']);
var admin = cp.spawn('node', ['./admin/server.js']);
 
var port = 80;
 
function fatalError(err){
console.log(err);
process.exit(1);
}
 
bouncy(function (req, bounce) {
req.on('error', function(error){
console.log(error);
});
 
if (req.headers.host === 'admin.site.com' || req.headers.host === 'admin.site.local') {
bounce(8001).on('error', function(err){
fatalError(err);
});
}
else if (req.headers.host === 'www.site.com' || req.headers.host === 'site.com' || req.headers.host === 'www.site.local' || req.headers.host === 'site.local') {
bounce(8002).on('error', function(err){
fatalError(err);
});
}
}).listen(port);
 
console.log('proxy started & listening on port', port);
 
www.on('error', function(error){
fatalError(error);
});
 
www.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
 
www.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
 
admin.on('error', function(error){
fatalError(error);
});
 
admin.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
 
admin.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
 
process.on('exit', function(){
www.kill('SIGHUP');
admin.kill('SIGHUP');
});
 
------------------
I get the following error:
 
net.js:722
self.fd = socket(self.type);
^
Error: EMFILE, Too many open files
at net.js:722:19
at Object.lookup (dns.js:153:45)
at Socket.connect (net.js:716:20)
at Object.createConnection (net.js:265:5)
at /Users/matt/Development/vayafeliz.node/node_modules/bouncy/lib/parse_args.js:47:31
at /Users/matt/Development/vayafeliz.node/node_modules/bouncy/index.js:72:20
at /Users/matt/Development/vayafeliz.node/proxy.js:27:7
at IncomingMessage.onHeaders (/Users/matt/Development/vayafeliz.node/node_modules/bouncy/index.js:55:13)
at IncomingMessage.emit (events.js:64:17)
at Parser.<anonymous> (/Users/matt/Development/vayafeliz.node/node_modules/bouncy/node_modules/parsley/lib/modes.js:135:21)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.