The following the log dump from my cf push :
2014-09-09T15:47:35.92+0530 [App/0] ERR 2014-09-09T15:47:35.97+0530 [DEA] OUT Instance (index 0) failed to start accepting connections 2014-09-09T15:47:55.71+0530 [DEA] OUT Starting app instance (index 0) with guid 20dba222-e0e6-453c-96a9-429940bc7002 2014-09-09T15:47:57.59+0530 [API] OUT App instance exited with guid 20dba222-e0e6-453c-96a9-429940bc7002 payload: {"cc_partition"=>"default", "droplet"=>"20dba222-e0e6-453c-96a9-429940bc7002", "version"=>"832505e6-a95d-4696-910e-a8d4a74a7005", "instance"=>"4ff487a75a674aa79b234cc1bd8f9a3d", "index"=>0, "reason"=>"CRASHED", "exit_status"=>0, "exit_description"=>"app instance exited", "crash_timestamp"=>1410257878} 2014-09-09T
This is how my manifest.yml file looks like :
applications:
- name: nodetestSDB
memory: 128M
command: node app.js
services:
- mongodbnode
This is how my package.json file looks like :
{
"name": "nodetest2",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"express": "~4.8.6",
"body-parser": "~1.6.6",
"cookie-parser": "~1.3.2",
"morgan": "~1.2.3",
"serve-favicon": "~2.0.1",
"debug": "~1.0.4",
"jade": "~1.5.0",
"mongodb": "*",
"monk": "*"
}
}
The environment variable in app.js :
if (process.env.VCAP_SERVICES) {
var env = JSON.parse(process.env.VCAP_SERVICES);
if (env['mongodb-2.2']) {
var mongo = env['mongodb-2.2'][0]['credentials'];
}
var db = monk(mongo.url);
}
Please take a look at my posts on using MongoDB with Bluemix in my blog. You can also check the code in GitHub abd Devops. Most likely you are not parsing the VCAP_SERVICES right. I have used both Node.js & NodeExpress
http://gigadom.wordpress.com/2014/07/27/a-bluemix-recipe-with-mongodb-and-node-js/ http://gigadom.wordpress.com/2014/08/04/elements-of-crud-with-nodeexpress-and-mongodb-using-enide-studio/ http://gigadom.wordpress.com/2014/08/07/spicing-up-a-ibm-bluemix-cloud-app-with-mongodb-and-nodeexpress/
Regards Ganesh
It looks like you have two different start commands for you app.
In manifest.yml you are using "node app.js" and in your package.json you are using "node ./bin/www".
Try having those two files match and that should help. Let me know if it doesn't work.
app.js:
console.log('VCAP SERVICES: ' + JSON.stringify(process.env.VCAP_SERVICES, null, 4));
var mongoUrl;
if(process.env.VCAP_SERVICES) {
var vcapServices = JSON.parse(process.env.VCAP_SERVICES);
for (var svcName in vcapServices) {
if (svcName.match(/^mongo.*/)) {
mongoUrl = vcapServices[svcName][0].credentials.uri;
mongoUrl = mongoUrl || vcapServices[svcName][0].credentials.url;
break;
}
}
}
else
{
mongoUrl = "localhost:27017/SScheduler";
}
console.log('Mongo URL: ' + mongoUrl);
// Database var mongo = require('mongoskin');
var db = mongo.db(mongoUrl, {native_parser:true}); -->through bluemix
//var db = mongo.db("mongodb://localhost:27017/nodetest2", {native_parser:true}); -->through local setup
i tried like this and it worked for both local and through bluemix