Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set environment variable in Meteor's provided server?

Tags:

meteor

I'd like to test meteor google analytics package on a remote server.

settings.json

{
  "public" : {
    "ga": {
      "account":"UA-dfgddhdh-5"
    }
  }
}

In a local server, I just pass in --settings option. I looked at http://meteorpedia.com/read/Environment_Variables and http://docs.meteor.com/#/full/meteor_settings but it's still unclear what I should do to set this environment variable inside meteor deploy. Thank you for your help!

EDIT:

if (Meteor.isServer) {
  Meteor.startup(function () {
    var settings = JSON.parse(
      '{"public" : {"ga": {"account":"UA-5555555-5"}}}'
    );
    process.env.METEOR_SETTINGS = settings;
  });
}

Is this the right approach? Also, https://github.com/datariot/meteor-ganalytics package requires this setting before the package itself is loaded. How do I ensure it?

like image 536
Maximus S Avatar asked Dec 24 '22 20:12

Maximus S


1 Answers

You can use, on the server side:

process.env.ENV_VARIABLE = "something"

instead of $ export ENV_VARIABLE='something'

like image 132
Tarang Avatar answered Mar 15 '23 08:03

Tarang