I have two instances of the same app hosted on Galaxy (staging and production). I want to be able to use process.env.NODE_ENV
to differentiate between them in my code. However, I can’t seem to get NODE_ENV
to be anything other than production
. This is what I’m using in my staging settings. Any ideas on how to get this to work?
"galaxy.meteor.com": {
"env": {
"ROOT_URL": "https://staging.touchmail.io",
"MONGO_URL": "",
"MONGO_OPLOG_URL": "",
"NODE_ENV": "staging"
}
}
Try to use two different settings file - ‘settings-staging.json’ and ‘settings-production.json’ pointing to two instances. And use these files in the command line deploy command for deploying in to the two instances
Hey, thanks for your reply. That’s actually exactly what I’m doing for each of my sites. This is how I’d deploy to staging, for example:
DEPLOY_HOSTNAME=galaxy.meteor.com NODE_ENV=staging meteor deploy staging.touchmail.io --settings settings/staging.json
The issue is that if I set NODE_ENV
to staging
within the settings/staging.json
it doesn’t set it on Galaxy. It’s always set to production
.
Oh ok…How about setting NODE_ENV variable when you startup your app and match it to your settings.json file. So what I mean is, in your settings.json file create a key in your “galaxy.meteor.com and call it say “Mode” = Staging” or “Mode” =“Production” depending on either your staging or production settings file.
Then in your server code you can set the NODE_ENV variable depending on the Mode.
So the pseudo code would be:
Meteor.startup(function(){
if galaxy.meteor.com.mode === "staging {
process.env.NODE_ENV = “staging” } else {
process.env.NODE_ENV = “production” }
It is kind of hacky. Not sure if it is going to work. Just an idea to try it out…
It’s a decent idea. I’ll give it a try and report back. I also have a support request in at Galaxy so we’ll see what they say too.
Galaxy support got back to me and they’ve decided it’s a bug.
1 Like
Good to know about the bug
isProduction
and isDevelopment
are based on the NODE_ENV
, so what happens if you set it to an arbitrary value? How about the debugOnly
and productionOnly
flags in packages? Note to self: Asking this in the issue might be a better idea
@timfletcher, I can conclude that you are using 1.3 and that 1.3 is working on Galaxy? At least the bug report talks about 1.3.
Yes, I’m using 1.3 on Galaxy and everything’s been working just fine so far.