如何更正无法接受连接的Bluemix Node.js应用程序
我今天早上在Bluemix上创build了一个新的Node.js应用程序,并下载了样板代码。 我在当地工作,然后把它推上去。 在Bluemix上,它拒绝启动。 根据日志的错误是:
Instance (index 0) failed to start accepting connections
所以我Googlesearch,在任何情况下,我find了结果,答案是我的应用程序试图使用特定的端口,而不是让Bluemix设置它。
好吧,但我正在设置主机/端口与模板使用的确切代码:
var appEnv = cfenv.getAppEnv(); // start server on the specified port and binding host app.listen(appEnv.port, function() { // print a message when the server starts listening console.log("server starting on " + appEnv.url); });
所以,如果这是不正确的,这意味着Bluemix告诉我下载的代码也是不正确的,我无法想象这是问题。
为了确定cfenv
是否有cfenv
,我已经用一些更复杂的Node.js应用程序testing了这段代码,并且它们在Bluemix上完美运行。
当您部署到Bluemix的应用程序无法启动时,该消息也会出现。 在Bluemix上,您可以执行以下几项操作来排查Node.js应用程序。
- 在用“cf日志”按下时尾巴login到另一个terminal。 检查失败后的日志,以查看在临时过程中是否有失败。
- 检查两个推荐位置之一的启动命令,在
package.json
中web: node <start-script>
或者在带有web: node <start-script>
的Procfile
web: node <start-script>
。 - 检查你的应用程序在本地工作。 首先(可选),使用“/ node_modules”创build一个
.cfignore
文件,以便将应用程序推送到Bluemix时,CF CLI不会推送node_modules的整个文件夹(因为它们将被dynamic安装)。 接下来,擦掉你的node_modules
目录,然后执行npm install --production
然后执行npm start
(或者你的自定义启动命令)。 这是Bluemix在尝试启动应用程序时所做的工作,因此您应该仔细检查它是否在本地运行。 - 最后,尝试加快你的记忆,尽pipe这不太可能,这就是你的应用程序无法启动的原因。
- 如何在bluemix上configurationsocket.io粘性会话
- Bluemix Node + Cloudant样板文件 – EOF错误
- 使用Cloudant Lite服务在Bluemix上的Node.js Web应用程序中收到500个查询错误
- 使用BlueMix的Node-RED编辑器和MQTT->debugging节点时出现意外的string
- Bluemix中的LoopBack应用程序的内存build议
- 适用于移动Web服务的Bluemix SSO
- 无法在Bluemix上以FIPS模式运行node.js应用程序
- Bluemix Single Sign On不显示login页面
- 如何将用户名和密码发送到在Bluemix上运行的node.js服务器?