I am trying to create a site and deploy in Bluemix, using node.js, mongodb (mongolabs) which displays data from mongodb. I created a collection - "caterer", using mongolabs. My app.js is as below :
var express = require('express'),
routes = require('./routes'),
cache = require('./routes/cache'),
http = require('http'),
path = require('path'),
mongodb = require('mongodb'),
url = require('url');
var mongo = {};
if (process.env.VCAP_SERVICES) { var env = JSON.parse(process.env.VCAP_SERVICES);
if (env['mongodb-2.4'])
{ mongo['url'] = env['mongodb-2.4'][0]['credentials']['uri']; } }
//With this as the connector var MongoClient = mongodb.MongoClient; var db = MongoClient.connect(mongo.url, function(err, db)
{ if(err) { console.log("failed to connect to the database"); }
else { console.log("connected to database");}
app.get('/', function(req, res)
{ mongodb.connect(mongo.url,function(err,conn)
{ var collection = db.get('caterer');
collection.find({},{},function(e,details)
{ res.render('index', { "details" : details }); }); }); });
when I push this to jazz hub, this is the error I see in Bluemix logs : BXNUI2034E: Error while getting instances resource. Cloud Foundry issued the following message: "Instance unavailable" See the Troubleshooting topics in the IBM Bluemix Documentation to check service status, review troubleshooting information, or for information about getting help.
这是控制台输出:
31-0800 [DEA] OUT 删除 id 为 9dfd06e6-fc10-4207-881a-9557403160b3 的应用程序的崩溃 2014-11-19T03:34:44.31-0800 [DEA] OUT 使用 guid 9dfd06e6-fc10- 停止应用程序实例(索引 0) 4207-881a-9557403160b3 2014-11-19T03:40:44.55-0800 [DEA] OUT 使用 guid 9dfd06e6-fc10-4207-881a-9557403160b3 2014-11-19T003:40:478 启动应用程序实例(索引 0) App/0] ERR 2014-11-19T03:40:47.88-0800 [App/0] ERR /home/vcap/app/app.js:86 2014-11-19T03:40:47.88-0800 [App/0]呃 }); 2014-11-19T03:40:47.89-0800 [App/0] ERR SyntaxError: Unexpected end of input 2014-11-19T03:40:47.89-0800 [App/0] ERR at Module._compile (module.js:439 :25) 2014-11-19T03:40:47.89-0800 [App/0] ERR 在 Object.Module._extensions..js (module.js:474:10) 2014-11-19T03:40:47.89-0800 [ App/0] Module.load 处的错误 (module.js:356: