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] GUID 9dfd06e6-fc10-4207-881a-9557403160b3 でアプリ インスタンス (インデックス 0) を開始していますアプリ/0] エラー 2014-11-19T03:40:47.88-0800 [アプリ/0] エラー /home/vcap/app/app.js:86 2014-11-19T03:40:47.88-0800 [アプリ/0]エラー}); 2014-11-19T03:40:47.89-0800 [App/0] ERR SyntaxError: 入力の予期しない終了 2014-11-19T03:40:47.89-0800 [App/0] Module._compile でのエラー (module.js:439 :25) 2014-11-19T03:40:47.89-0800 [App/0] Object.Module._extensions..js でのエラー (module.js:474:10) 2014-11-19T03:40:47.89-0800 [ App/0] Module.load でのエラー (module.js:356: