我正在尝试将我的角度快速网络应用程序推送到bluemix,但我收到此错误
2016-04-05T20:12:50.96-0300 [App/0] OUT > angular-expess-seed-
with-html@0.0.1 start /home/vcap/app
2016-04-05T20:12:50.96-0300 [App/0] OUT > node app.js
2016-04-05T20:12:51.19-0300 [App/0] OUT Express server listening
on port 3000 in production mode
2016-04-05T20:13:50.37-0300 [DEA/34] ERR Instance (index 0) failed
to start accepting connections
2016-04-05T20:13:50.39-0300 [API/2] OUT App instance exited with
guid b3554c4b-11f5-433f-891e-1df16605df80 payload:
{"cc_partition"=>"default", "droplet"=>"b3554c4b-11f5-433f-891e-
1df16605df80", "version"=>"36d8b569-d38a-465d-8bc6-b14ffd13b413",
"instance"=>"dbd3566e0ef348d9b9f483a32e8fed89", "index"=>0,
"reason"=>"CRASHED", "exit_status"=>-1, "exit_description"=>"failed to
accept connections within health check timeout",
"crash_timestamp"=>1459898030}
2016-04-05T20:13:50.40-0300 [App/0] ERR
2016-04-05T20:14:16.36-0300 [DEA/24] OUT Starting app instance
(index 0) with guid b3554c4b-11f5-433f-891e-1df16605df80
首先,它抱怨启动脚本丢失我已修复该部分,但没有这样的错误。
答案 0 :(得分:2)
我可以从下面的错误中看到:
Express server listening
on port 3000 in production mode
您的Node.js应用程序正在尝试在端口3000中侦听。这适用于本地环境,但对于Bluemix,您必须从Cloud Foundry(CF)环境获取端口。
以下是执行此操作的示例代码:
// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
var cfenv = require('cfenv');
// get the app environment from Cloud Foundry
var appEnv = cfenv.getAppEnv();
// start server on the specified port and binding host
app.listen(appEnv.port, '0.0.0.0', function() {
// print a message when the server starts listening
console.log("server starting on " + appEnv.url);
});