【发布时间】:2016-01-22 14:46:34
【问题描述】:
所以我已经通过 git 将我的 express/mongodb 应用程序部署到我的 Azure Web 应用程序,当我打开应用程序的链接时,它一直在加载并显示一个黑页,我的路由不起作用,但静态文件只加载美好的。 所以我去看日志,我得到了这个。
D:\home\site\wwwroot\node_modules\mongodb\lib\server.js:236
process.nextTick(function() { throw err; })
^
MongoError: server 127.0.0.1:3000 sockets closed
at null.<anonymous> (D:\home\site\wwwroot\node_modules\mongodb-core\lib\topologies\server.js:330:47)
at g (events.js:260:16)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at null.<anonymous> (D:\home\site\wwwroot\node_modules\mongodb-core\lib\connection\pool.js:105:12)
at g (events.js:260:16)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at Socket.<anonymous> (D:\home\site\wwwroot\node_modules\mongodb-core\lib\connection\connection.js:145:12)
at Socket.g (events.js:260:16)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at TCP._onclose (net.js:469:12)
npm ERR! Windows_NT 6.2.9200
npm ERR! argv "D:\\Program Files (x86)\\nodejs\\4.2.3\\node.exe" "D:\\Program Files (x86)\\npm\\3.5.1\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v4.2.3
npm ERR! npm v3.5.1
npm ERR! code ELIFECYCLE
npm ERR! cinemat_iq@0.9.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cinemat_iq@0.9.0 start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the cinemat_iq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs cinemat_iq
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls cinemat_iq
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\home\site\wwwroot\npm-debug.log
所以问题似乎出在 mongodb 的连接命令中,我目前将其作为
mongoose.connect('mongodb://127.0.0.1:3000/myapp');
我尝试更改为 localhost 而不是 127.0.0.1,并尝试了不同的端口,都导致相同的错误。
经过一些谷歌搜索/stackoverflowing 之后,我需要删除 mongodb 中的“锁定文件”,然后修复/重新启动 mongodb 服务。 问题是我无法使用 Azure 控制台(基于 Windows)找到此文件,并且无法运行任何 mongo 或 mongod 命令(它不被识别为内部或外部命令)。
那么我该怎么做才能让我的应用在 Azure 上运行?
【问题讨论】: