0

I am trying to use an environment variable to not set the "http address", because the IP address may change while use to AWS machine. How can I use an environment variable where it find the HTTPAddresses? Here I use the localhost address but at AWS I can not use like so. Any suggestion how to solve this problem?

var envv = (process.env.NSQD_RETH || "localhost:4161").split(",");
var connection = null;
r.connect( {host: 'localhost', port: 28015, db:'test', authKey:''},     function(err, conn) {
if (err) throw err;
connection = conn;
var eventreader;
eventreader = new nsq.Reader('ev_topic', 'ev_channel', {
    lookupdHTTPAddresses: envv
});

Thanks in advance.

rivermont
  • 223
  • 2
  • 12
Istiak Mahmood
  • 2,330
  • 8
  • 31
  • 73
  • You are using already the environment-var `process.env.NSQD_RETH` - why can't you just use an env-var for the rethinkdb-host on aws? Which problems do you face? – alwe May 09 '15 at 22:42
  • because at --- var envv = (process.env.NSQD_RETH || "localhost:4161").split(","); //// i am using localhost but in real i have to use AWS , so how do write something that when i come to this point "lookupdHTTPAddresses: envv" it fulfil the http address – Istiak Mahmood May 09 '15 at 23:08
  • 1
    start the node-process with this environment-var and you should be done: `NSQD_RETH=YOUR.AWS.HOST.COM node server.js` – alwe May 09 '15 at 23:16
  • i actually get it before but my problem is how can i write the program at node.js application var envv = (process.env.NSQD_RETH || "localhost:4161").split(","); fot this line of code, showuld i write like so ... var envv = (process.env.NSQD_RETH || AWS.HOST.COM).split(","); – Istiak Mahmood May 09 '15 at 23:34
  • You can only have one rethinkdb-host to connect, so you should only have one evn-var for rethinkdb at one time. – alwe May 10 '15 at 09:20
  • i have to listen NSQ topic and save it to rethinkdb, so for this line------ var envv = (process.env.NSQD_RETH || "localhost:4161").split(","); ///// what i should put for localhost or http address – Istiak Mahmood May 10 '15 at 10:30

0 Answers0