I using cloud9 ide coding new project. When I deploy on cloudfoundry from cloud9ide. I have error
Application failed to start. Please note that CloudFoundry uses a different port to listen to. When calling ‘listen()’ use it like ‘.listen(process.env.PORT || process.env.VCAP_APP_PORT)’.
This is my source
var port = (process.env.VMC_APP_PORT || 3000);
var host = (process.env.VCAP_APP_HOST || ‘localhost’);
var http = require(‘http’);
var env = process.env.VCAP_SERVICES ? JSON.parse(process.env.VCAP_SERVICES) : null;
var mongodata = env[‘mongodb-1.8’][0][‘credentials’];
http.createServer(function (req, res) {
res.writeHead(200, {‘Content-Type’: ‘text/plain’});
res.end(‘Hello World\n’ + env);
}).listen(port, host);
This source have error when I get mongo object
var mongodata = env[‘mongodb-1.8’][0][‘credentials’];
But not have this line deploy successful
Please help me !!
Thanks so much
As the error in the cloud9 console probably tells you (as it tells me when i try this 🙂 ):
So there is no entry in
VCAP_SERVICEScalled like that. When Iconsole.logtheprocess.envvariable, there isn’t even any service listed.So you’ll have to install the mongodb service for your app. Fastest to do this is via the CF VMC tools (can’t run this in cloud9 at the moment, so you’ll have to install this locally):
Then it’ll start up fine.
N.B. You can probably fix this in the .yml file, but I don’t know how to do this 🙂