2

I am trying to deploy an application prototype to openshift. It works locally with mongodb at 127.0.0.1. I am trying to get it to respect process.env.OPENSHIFT_MONGODB_DB_URL when in the openshift environment but that variable is not accessible to my nodejs cartridge at runtime.

I can see that it is being set in my application's shell environment. When I do rhc ssh and then export I see OPENSHIFT_MONGODB_DB_URL=[full_url_with_password] and it all looks good.

But when, in my node.js application, I call process.env.OPENSHIFT_MONGODB_DB_URL it returns undefined.

To double check, I did a console.log(util.inspect(process.env)) from within my node.js app, and what I saw was different from what I see within my appication's secure shell. No OPENSHIFT_MONGODB_* variables were in the environment that is exposed to my node.js app.

How can I access variables across different cartridges? Or is this a configuration error?

VictorB
  • 578
  • 3
  • 14
  • It appears it may have been an issue with the order in which the cartridges are started? After some stopping and starting of the app/cartridges the problem went away. – VictorB Feb 14 '15 at 02:15

1 Answers1

1

It sounds like a configuration error. I have a similar application and

console.log(util.inspect(process.env)) 

gives me a clear picture of the mongodb environment variables.

The developers page indicates that:

Database environment variables pertain to a database, if one exists, and are used to connect an application to a database. Note that these connections are only available to an application internally; you cannot connect from an external source.

This suggests, to me, that the nodejs is external to the mongodb installation. I have an idea that it can be verified with the command:

rhc app show OPENSHIFT_APP_NAME

It might lead to the source of the problem. A correctly configured app would have nodejs and mongodb in this list.

piisexactly3
  • 779
  • 7
  • 16