为什么未检测到 Cloudfoundry (Bluemix) 应用程序崩溃
Why Cloudfoundry (Bluemix) app crash is not detected
嗨,
我在使用 Cloudfoundry 的 Bluemix 上有一个 node.js 应用程序 运行。当我的应用程序检测到致命错误时,它会停止接受连接并在日志记录完成后以退出代码 1 退出。
我在想,Bluemix 会检测到这一点并尝试重新启动应用程序,但目前它没有在控制台中显示任何问题,只是负载平衡器 returns 503 状态代码。
这是输出 cf 日志 returns
TIMESTAMP [App/0] OUT FATAL ERROR WITH STACKTRACE
TIMESTAMP [App/0] ERR npm ERR! Linux 3.13.0-39-generic
TIMESTAMP [App/0] ERR npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"
TIMESTAMP [App/0] ERR npm ERR! node v0.12.7
TIMESTAMP [App/0] ERR npm ERR! npm v2.11.3
TIMESTAMP [App/0] ERR npm ERR! code ELIFECYCLE
TIMESTAMP [App/0] ERR npm ERR! myapp@0.1.0 start: `node app/app.js`
TIMESTAMP [App/0] ERR npm ERR! Exit status 1
TIMESTAMP [App/0] ERR npm ERR!
TIMESTAMP [App/0] ERR npm ERR! Failed at the myapp@0.1.0 start script 'node app/app.js'.
TIMESTAMP [App/0] ERR npm ERR! This is most likely a problem with the myapp package,
TIMESTAMP [App/0] ERR npm ERR! not with npm itself.
TIMESTAMP [App/0] ERR npm ERR! Tell the author that this fails on your system:
TIMESTAMP [App/0] ERR npm ERR! node app/app.js
TIMESTAMP [App/0] ERR npm ERR! You can get their info via:
TIMESTAMP [App/0] ERR npm ERR! npm owner ls myapp
TIMESTAMP [App/0] ERR npm ERR! There is likely additional logging output above.
TIMESTAMP [App/0] ERR npm ERR! Please include the following file with any support request:
TIMESTAMP [App/0] ERR npm ERR! /home/vcap/app/npm-debug.log
TIMESTAMP [RTR/2] OUT myapp.bluemix.net - [TIMESTAMP] "GET /myroute HTTP/1.1" 503 0 89 "-" "-" PUBLICIP:41145 x_forwarded_for:"IP" vcap_request_id:requestID response_time:0.002571320 app_id:myappId
TIMESTAMP [App/0] OUT TIMESTAMP http: proxy error: dial tcp 127.0.0.1:61872: connection refused
TIMESTAMP [App/0] OUT TIMESTAMP myapp.bluemix.net - [TIMESTAMP] GET /myroute HTTP/1.1 - 467.106us
TIMESTAMP [App/0] OUT TIMESTAMP http: proxy error: dial tcp 127.0.0.1:61872: connection refused
TIMESTAMP [App/0] OUT TIMESTAMP myapp.bluemix.net - [TIMESTAMP] GET /doc HTTP/1.1 - 289.874us
TIMESTAMP [RTR/0] OUT TIMESTAMP - [TIMESTAMP] "GET /myroute HTTP/1.1" 503 0 89 "https://myapp.bluemix.net" (https://myapp.bluemix.net) "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0" PUBLICIP:39419 x_forwarded_for:"IP" vcap_request_id:REQUESTID response_time:0.001849779 app_id:APP_ID
TIMESTAMP [App/0] OUT TIMESTAMP http: proxy error: dial tcp 127.0.0.1:61872: connection refused
TIMESTAMP [App/0] OUT TIMESTAMP TIMESTAMP - [TIMESTAMP] GET /static/swagger/images/favicon-16x16.png HTTP/1.1 - 1.150624ms
TIMESTAMP [RTR/1] OUT myapp.bluemix.net - [TIMESTAMP] "GET /static/swagger/images/favicon-16x16.png HTTP/1.1" 503 0 89 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0" PUBLICIP:38110 x_forwarded_for:"IP" vcap_request_id:REQUESTID response_time:0.004067078 app_id:APPID
知道这里出了什么问题吗?我已经通过运行"npm start; echo $?"在本地测试过了。它返回 1,因此退出代码应该有效。
编辑:
manifest.yml:
applications:
- disk_quota: 1024M
host: myapp
name: myapp
path: .
domain: mybluemix.net
instances: 1
memory: 512M
env:
BLUEMIX_APP_MGMT_ENABLE: devconsole+shell
package.json 看起来像:
{
"name": "myApp",
"description": "MyDescription",
"version": "0.1.0",
"engines" : { "node" : ">=0.12.7" },
"dependencies": {
"express": "4.13.3",
"express-session": "1.11.3",
...
},
"devDependencies": {
"grunt": "0.4.5",
"mocha": "2.2.5",
...
},
"scripts": {
"test": "grunt dev-test",
"start": "node app/app.js"
},
"repository": {
"type": "git",
"url": "..."
}
}
Bluemix 正在通过解释 npm start 命令在启动时生成一个 procfile。
我正在打电话给我的 app/app.js
var app = express();
app.set("port", process.env.VCAP_APP_PORT);
...
var server = http.createServer(app);
server.listen(app.get("port"), function () {
logger.info("Express server listening on port" + app.get("port"));
});
环境看起来像:
cf env myapp
Getting env variables for app myapp in org myOrg / space mySpace as my@mail.com...
OK
System-Provided:
{
"VCAP_APPLICATION": {
"application_name": "myApp",
"application_uris": [
"myapp.mybluemix.net"
],
"application_version": "HASH",
"limits": {
"disk": 1024,
"fds": 16384,
"mem": 512
},
"name": "myApp",
"space_id": "HASH",
"space_name": "mySpace",
"uris": [
"myapp.mybluemix.net",
],
"users": null,
"version": "HASH"
}
}
User-Provided:
BLUEMIX_APP_MGMT_ENABLE: devconsole+shell
No running env variables have been set
No staging env variables have been set
需要知道的重要一点是,该应用程序会运行几分钟,在发生致命错误后应重新启动。
清单文件和文件夹结构正常,因此不会放错文件夹。
cf 事件显示:
$ cf events myApp
Getting events for app myApp in org myOrg / space mySpace as my@mail.com...
time event actor description
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.map-route my@mail.com
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.unmap-route my@mail.com
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.map-route my@mail.com
TIMESTAMP audit.app.update my@mail.com state: STARTED
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.map-route my@mail.com
TIMESTAMP audit.app.create my@mail.com disk_quota: 1024, instances: 1, memory: 512, state: STOPPED, environment_json: PRIVATE DATA HIDDEN
如果我用浏览器连接,显示如下:
503 Service Unavailable: The server is not available now. Please try your request later.
在 Bluemix 控制台上它显示为 运行:
运行
之后
cf restart myapp
该应用程序再次运行。
因为你在请求
BLUEMIX_APP_MGMT_ENABLE: devconsole+shell
它阻碍了容器被杀死,你想在崩溃后调试它,对吗?看起来像预期的那样工作。
HP
嗨,
我在使用 Cloudfoundry 的 Bluemix 上有一个 node.js 应用程序 运行。当我的应用程序检测到致命错误时,它会停止接受连接并在日志记录完成后以退出代码 1 退出。
我在想,Bluemix 会检测到这一点并尝试重新启动应用程序,但目前它没有在控制台中显示任何问题,只是负载平衡器 returns 503 状态代码。
这是输出 cf 日志 returns
TIMESTAMP [App/0] OUT FATAL ERROR WITH STACKTRACE
TIMESTAMP [App/0] ERR npm ERR! Linux 3.13.0-39-generic
TIMESTAMP [App/0] ERR npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"
TIMESTAMP [App/0] ERR npm ERR! node v0.12.7
TIMESTAMP [App/0] ERR npm ERR! npm v2.11.3
TIMESTAMP [App/0] ERR npm ERR! code ELIFECYCLE
TIMESTAMP [App/0] ERR npm ERR! myapp@0.1.0 start: `node app/app.js`
TIMESTAMP [App/0] ERR npm ERR! Exit status 1
TIMESTAMP [App/0] ERR npm ERR!
TIMESTAMP [App/0] ERR npm ERR! Failed at the myapp@0.1.0 start script 'node app/app.js'.
TIMESTAMP [App/0] ERR npm ERR! This is most likely a problem with the myapp package,
TIMESTAMP [App/0] ERR npm ERR! not with npm itself.
TIMESTAMP [App/0] ERR npm ERR! Tell the author that this fails on your system:
TIMESTAMP [App/0] ERR npm ERR! node app/app.js
TIMESTAMP [App/0] ERR npm ERR! You can get their info via:
TIMESTAMP [App/0] ERR npm ERR! npm owner ls myapp
TIMESTAMP [App/0] ERR npm ERR! There is likely additional logging output above.
TIMESTAMP [App/0] ERR npm ERR! Please include the following file with any support request:
TIMESTAMP [App/0] ERR npm ERR! /home/vcap/app/npm-debug.log
TIMESTAMP [RTR/2] OUT myapp.bluemix.net - [TIMESTAMP] "GET /myroute HTTP/1.1" 503 0 89 "-" "-" PUBLICIP:41145 x_forwarded_for:"IP" vcap_request_id:requestID response_time:0.002571320 app_id:myappId
TIMESTAMP [App/0] OUT TIMESTAMP http: proxy error: dial tcp 127.0.0.1:61872: connection refused
TIMESTAMP [App/0] OUT TIMESTAMP myapp.bluemix.net - [TIMESTAMP] GET /myroute HTTP/1.1 - 467.106us
TIMESTAMP [App/0] OUT TIMESTAMP http: proxy error: dial tcp 127.0.0.1:61872: connection refused
TIMESTAMP [App/0] OUT TIMESTAMP myapp.bluemix.net - [TIMESTAMP] GET /doc HTTP/1.1 - 289.874us
TIMESTAMP [RTR/0] OUT TIMESTAMP - [TIMESTAMP] "GET /myroute HTTP/1.1" 503 0 89 "https://myapp.bluemix.net" (https://myapp.bluemix.net) "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0" PUBLICIP:39419 x_forwarded_for:"IP" vcap_request_id:REQUESTID response_time:0.001849779 app_id:APP_ID
TIMESTAMP [App/0] OUT TIMESTAMP http: proxy error: dial tcp 127.0.0.1:61872: connection refused
TIMESTAMP [App/0] OUT TIMESTAMP TIMESTAMP - [TIMESTAMP] GET /static/swagger/images/favicon-16x16.png HTTP/1.1 - 1.150624ms
TIMESTAMP [RTR/1] OUT myapp.bluemix.net - [TIMESTAMP] "GET /static/swagger/images/favicon-16x16.png HTTP/1.1" 503 0 89 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0" PUBLICIP:38110 x_forwarded_for:"IP" vcap_request_id:REQUESTID response_time:0.004067078 app_id:APPID
知道这里出了什么问题吗?我已经通过运行"npm start; echo $?"在本地测试过了。它返回 1,因此退出代码应该有效。
编辑:
manifest.yml:
applications:
- disk_quota: 1024M
host: myapp
name: myapp
path: .
domain: mybluemix.net
instances: 1
memory: 512M
env:
BLUEMIX_APP_MGMT_ENABLE: devconsole+shell
package.json 看起来像:
{
"name": "myApp",
"description": "MyDescription",
"version": "0.1.0",
"engines" : { "node" : ">=0.12.7" },
"dependencies": {
"express": "4.13.3",
"express-session": "1.11.3",
...
},
"devDependencies": {
"grunt": "0.4.5",
"mocha": "2.2.5",
...
},
"scripts": {
"test": "grunt dev-test",
"start": "node app/app.js"
},
"repository": {
"type": "git",
"url": "..."
}
}
Bluemix 正在通过解释 npm start 命令在启动时生成一个 procfile。
我正在打电话给我的 app/app.js
var app = express();
app.set("port", process.env.VCAP_APP_PORT);
...
var server = http.createServer(app);
server.listen(app.get("port"), function () {
logger.info("Express server listening on port" + app.get("port"));
});
环境看起来像:
cf env myapp
Getting env variables for app myapp in org myOrg / space mySpace as my@mail.com...
OK
System-Provided:
{
"VCAP_APPLICATION": {
"application_name": "myApp",
"application_uris": [
"myapp.mybluemix.net"
],
"application_version": "HASH",
"limits": {
"disk": 1024,
"fds": 16384,
"mem": 512
},
"name": "myApp",
"space_id": "HASH",
"space_name": "mySpace",
"uris": [
"myapp.mybluemix.net",
],
"users": null,
"version": "HASH"
}
}
User-Provided:
BLUEMIX_APP_MGMT_ENABLE: devconsole+shell
No running env variables have been set
No staging env variables have been set
需要知道的重要一点是,该应用程序会运行几分钟,在发生致命错误后应重新启动。
清单文件和文件夹结构正常,因此不会放错文件夹。
cf 事件显示:
$ cf events myApp
Getting events for app myApp in org myOrg / space mySpace as my@mail.com...
time event actor description
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.map-route my@mail.com
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.unmap-route my@mail.com
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.map-route my@mail.com
TIMESTAMP audit.app.update my@mail.com state: STARTED
TIMESTAMP audit.app.update my@mail.com
TIMESTAMP audit.app.map-route my@mail.com
TIMESTAMP audit.app.create my@mail.com disk_quota: 1024, instances: 1, memory: 512, state: STOPPED, environment_json: PRIVATE DATA HIDDEN
如果我用浏览器连接,显示如下:
503 Service Unavailable: The server is not available now. Please try your request later.
在 Bluemix 控制台上它显示为 运行:
cf restart myapp
该应用程序再次运行。
因为你在请求
BLUEMIX_APP_MGMT_ENABLE: devconsole+shell
它阻碍了容器被杀死,你想在崩溃后调试它,对吗?看起来像预期的那样工作。
HP