From a019d7720599e70e1987bda1e737c72a87966ab3 Mon Sep 17 00:00:00 2001 From: cubedro Date: Wed, 18 Feb 2015 00:15:34 +0200 Subject: [PATCH] fixed env vars --- bin/build.sh | 7 +------ lib/node.js | 14 ++++++++++++-- package.json | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index c3248f7..7dc3a68 100644 --- a/bin/build.sh +++ b/bin/build.sh @@ -54,9 +54,4 @@ cd www sudo npm install sudo npm install pm2 -g -export EC2_INSTANCE_ID=$(ec2metadata --instance-id) -export ETH_VERSION="$(/home/ubuntu/bin/eth -V)" - -# pm2 start processes.json -# pm2 startup ubuntu -# pm3 save \ No newline at end of file +pm2 start processes.json diff --git a/lib/node.js b/lib/node.js index 71fc2bf..23c86b4 100644 --- a/lib/node.js +++ b/lib/node.js @@ -1,6 +1,7 @@ var web3 = require('ethereum.js'); var _ = require('lodash'); var os = require('os'); +var shelljs = require('shelljs'); var Primus = require('primus'), Emitter = require('primus-emit'), @@ -12,6 +13,15 @@ Socket = Primus.createSocket({ plugin: {emitter: Emitter} }); +var INSTANCE_NAME, + ETH_VERSION; + +if(process.env.NODE_ENV == 'production') +{ + INSTANCE_NAME = shelljs.exec('ec2metadata --instance-id', {silent: true}).output; + ETH_VERSION = shelljs.exec('eth -V', {silent: true}).output; +} + var socket = new Socket(process.env.WS_SERVER || 'ws://localhost:3000'); var MAX_BLOCKS_HISTORY = 12, @@ -22,8 +32,8 @@ function Node() var self = this; this.info = { - name: process.env.EC2_INSTANCE_ID || os.hostname(), - node: process.env.ETH_VERSION || 'eth version 0.8.1', + name: INSTANCE_NAME || (process.env.EC2_INSTANCE_ID || os.hostname()), + node: ETH_VERSION || (process.env.ETH_VERSION || 'eth version 0.8.1'), os: os.platform(), os_v: os.release() }; diff --git a/package.json b/package.json index 8885523..1195f10 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "lodash": "^3.2.0", "primus": "^2.4.12", "primus-emit": "^0.1.2", + "shelljs": "^0.3.0", "ws": "^0.7.1" }, "scripts": {