0

I'm learning to use node.js and I wrote a little test app with express and mongoose.

it working perfect on my local machine. but after I uploaded it to Appfog, the DB start to behave very strange. as you can see here:

http://agoo.eu01.aws.af.cm/users

the first change seems te happend (sometimes), but after that, it act vary weird. press F5 few time and it show the new change and sometimes it doesn't

more than that, sometime I open the app after a while and the change it there, but not always.

this is the app.js code

http://jsbin.com/egotam/1/edit

if there is any need for any other files I will gladly provide

it drivring me nuts for 2 days..

thank you in advance!

Asaf Katz
  • 4,608
  • 4
  • 37
  • 42

1 Answers1

0

This documentation page should help: https://docs.appfog.com/languages/node

First of all, you need to change your app port to process.env.VCAP_APP_PORT. That means changing app.set('port', process.env.PORT || 3000) to app.set('port', process.env.VCAP_APP_PORT || 3000) in your app.js file.

Then, you need to rewire your database connection. First, remove the line mongourl = require('./env_settings') and replace it with the following:

var env = JSON.parse(process.env.VCAP_SERVICES);
var mongourl = ['mongodb-1.8'][0]['credentials'];

Now, your mongoose.connect(mongourl) will be properly configured for a Cloud Foundry environment instead of to your local environment, as it was configured previously.

  • thank you for the answer! it seems that I skipped the part in the documentation, it seems now that there is some other problem when I upload the app again, this is the log: http://jsbin.com/ayojuq/1/edit could you help me drop light on it? – Asaf Katz Jan 11 '13 at 20:39