开发者

Too many open files using child_process

I get the following error only on my Rackspace Ubuntu Maverick instance...but not on my local Ubuntu Lucid VM:

pipe(): Too many open files
pipe(): Too many o开发者_如何学Gopen files

child_process.js:223
  var fds = this._internal.spawn(path,
                           ^
Error: Error spawning
    at ChildProcess.spawn (child_process.js:223:28)
    at child_process.js:10:15
    etc..etc..

The code that generates it:

function getHeader(url, callback)
{
  var client = spawn('curl', ['-I', url]);
  client.stdout.on('data', function(data)
  {
    client.kill('SIGTERM');
    callback(data.toString('utf8'));
  });
}


It would be helpful to know how low your hosting provider has set the file limit: ulimit -n will tell you what the setrlimits(2) limit is on the number of open file descriptors per process. Typical installs use 1024. They may have set it much lower to limit in-kernel memory use.

There are hard limits, which you can only raise by asking Rackspace politely (unless you have write access to e.g. /etc/security/limits.conf), and soft limits, which can be raised up to the hard limit. They may have set the soft limits lower, to try to keep resource use down, but keep the hard limit higher.

It would also be helpful to know how many file descriptors node is currently using. While you're logged in, check /proc/$(pidof node.js)/fd/ to see how many files are open. Perhaps you're not closing files or sockets or pipes as quickly as they could be closed?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜