Node.js,path.js在很多用户连接到应用程序后崩溃

时间:2014-01-21 14:30:33

标签: javascript node.js express path.js

大家好我有一个用Express.js编写的应用程序,我使用socket.io向用户显示实时数据。

当有更多然后让网站上的10个用户突然节点服务器崩溃并且我收到此错误

path.js:309 var path = (i >= 0) ? arguments[i] : process.cwd();

即使我独自在网站上,我多次刷新页面,或者只是停留在网站上并点击页面我得到同样的错误,有谁知道如何解决这个问题?

编辑:这是整个错误

path.js:309
      var path = (i >= 0) ? arguments[i] : process.cwd();
                                                   ^
Error: EMFILE, too many open files
    at Object.exports.resolve (path.js:309:52)
    at ExpressHandlebars.extend.loadTemplate (/Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/lib/express-handlebars.js:111:25)
    at ExpressHandlebars.load (/Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/lib/express-handlebars.js:153:18)
    at /Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/node_modules/async/lib/async.js:224:13
    at /Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/node_modules/async/lib/async.js:108:13
    at Array.forEach (native)
    at _each (/Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/node_modules/async/lib/async.js:32:24)
    at async.each (/Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/node_modules/async/lib/async.js:107:9)
    at _asyncMap (/Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/node_modules/async/lib/async.js:223:9)
    at Object.map (/Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/node_modules/async/lib/async.js:201:23)
    at ExpressHandlebars.mapTemplates (/Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/lib/express-handlebars.js:157:19)
    at fn (/Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/node_modules/async/lib/async.js:579:34)
    at Object._onImmediate (/Users/sredoje/Downloads/expressjs-template/node_modules/express3-handlebars/node_modules/async/lib/async.js:495:34)
    at processImmediate [as _immediateCallback] (timers.js:330:15)
>> application exited with code 

8

1 个答案:

答案 0 :(得分:2)

检查出来:https://github.com/paulmillr/chokidar/issues/45

看起来这是一个“太多打开文件”错误,如果您的应用与文件系统中的大量文件进行交互,则可能会发生此错误。你没有说明你的平台是什么,我假设Linux,通过链接建议的修复是你的ulimit。

完整的引用修复:

  

EMFILE表示打开的文件太多。早午餐监视所有项目文件,它通常是一个非常大的数字。您可以使用命令ulimit -n <number>将最大打开文件数设置为更大的数字来修复此错误(10000应该足够了)。