大家好,我有一个用 Express.js 编写的应用程序,我使用 socket.io 向用户显示实时数据。
当有更多用户时,假设网站上有 10 个用户突然 Node 服务器崩溃,我收到此错误
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
最佳答案
看看这个:https://github.com/paulmillr/chokidar/issues/45
看起来这是一个“打开文件太多”错误,如果您的应用程序与文件系统中的大量文件交互,则可能会发生这种情况。您没有指出您的平台是什么,我假设是 Linux,链接中建议的修复是提高您的 ulimit。
完整引用的修复:
EMFILE
means there are too many open files. Brunch watches all your project files and it's usually a pretty big number. You can fix this error with setting max opened file count to a bigger number using the commandulimit -n <number>
(10000 should be enough).
关于javascript - 许多用户连接到应用程序后 Node.js 、 path.js 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21260966/