From 83a3edfdbbae5a7d0a288709b2a0142f09087311 Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 02:43:34 +0300 Subject: [PATCH 1/5] fixed gasPrice --- lib/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node.js b/lib/node.js index 1ca91ec..e93a84e 100644 --- a/lib/node.js +++ b/lib/node.js @@ -346,7 +346,7 @@ Node.prototype.getStats = function() } this.stats.mining = web3.eth.mining; - this.stats.gasPrice = web3.eth.gasPrice.toString(10); + this.stats.gasPrice = web3.toBigNumber(web3.eth.gasPrice).toString(10); this.stats.listening = web3.net.listening; } From 6d59e9d291f65cbce3ac35759ac5dd396d0e9931 Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 02:49:31 +0300 Subject: [PATCH 2/5] added update script --- bin/build.sh | 2 +- bin/update.sh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 bin/update.sh diff --git a/bin/build.sh b/bin/build.sh index 1739962..5733011 100644 --- a/bin/build.sh +++ b/bin/build.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash echo "You're about to install ethereum. Please choose one of the following:" echo "1. eth" diff --git a/bin/update.sh b/bin/update.sh new file mode 100644 index 0000000..c44ff33 --- /dev/null +++ b/bin/update.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if [[ -f /usr/bin/geth ]]; +then + ethtype="geth" +else + ethtype="eth" +fi + +pm2 kill +sudo apt-get remove $eth -y + +sudo apt-get clean +sudo add-apt-repository -y ppa:ethereum/ethereum +sudo add-apt-repository -y ppa:ethereum/ethereum-dev +sudo apt-get update -y +sudo apt-get upgrade -y + +sudo apt-get install $eth + +cd ~/bin/www +git pull +sudo npm update +cd .. +pm2 start processes.json From 6ac4c34c6793d521bf5a0c9454c97d6e19b847de Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 03:56:08 +0300 Subject: [PATCH 3/5] added colors to bash scripts --- bin/build.sh | 30 ++++++++++++++++++++++++++++-- bin/eth.sh | 0 bin/update.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 76 insertions(+), 4 deletions(-) mode change 100644 => 100755 bin/build.sh mode change 100644 => 100755 bin/eth.sh mode change 100644 => 100755 bin/update.sh diff --git a/bin/build.sh b/bin/build.sh old mode 100644 new mode 100755 index 5733011..0a96b62 --- a/bin/build.sh +++ b/bin/build.sh @@ -1,6 +1,32 @@ #!/bin/bash -echo "You're about to install ethereum. Please choose one of the following:" +# setup colors +red=`tput setaf 1` +green=`tput setaf 2` +cyan=`tput setaf 6` +bold=`tput bold` +reset=`tput sgr0` + +heading() +{ + echo + echo "${cyan}==>${reset}${bold} $1${reset}" +} + +success() +{ + echo + echo "${green}==>${bold} $1${reset}" +} + +error() +{ + echo + echo "${red}==>${bold} Error: $1${reset}" +} + +heading "You're about to install ethereum." +echo "Please choose one of the following:" echo "1. eth" echo "2. geth" while true; do @@ -12,7 +38,7 @@ while true; do esac done -echo "Installing" $ethtype +heading "Installing" $ethtype cd ~ diff --git a/bin/eth.sh b/bin/eth.sh old mode 100644 new mode 100755 diff --git a/bin/update.sh b/bin/update.sh old mode 100644 new mode 100755 index c44ff33..5949cc5 --- a/bin/update.sh +++ b/bin/update.sh @@ -1,25 +1,71 @@ #!/bin/bash +# setup colors +red=`tput setaf 1` +green=`tput setaf 2` +cyan=`tput setaf 6` +bold=`tput bold` +reset=`tput sgr0` + +heading() +{ + echo + echo "${cyan}==>${reset}${bold} $1${reset}" +} + +success() +{ + echo + echo "${green}==>${bold} $1${reset}" +} + +error() +{ + echo + echo "${red}==>${bold} Error: $1${reset}" +} + +heading "Updating ethereum" + +# figure out what we have to update if [[ -f /usr/bin/geth ]]; then ethtype="geth" + success "Found geth" else - ethtype="eth" + if [[ -f /usr/bin/geth ]]; + then + ethtype="eth" + success "Found eth" + else + error "Couldn't find ethereum" + exit 0 + fi fi +heading "Stopping processes" pm2 kill + +heading "Removing ethereum" sudo apt-get remove $eth -y +heading "Updating repos" sudo apt-get clean sudo add-apt-repository -y ppa:ethereum/ethereum sudo add-apt-repository -y ppa:ethereum/ethereum-dev sudo apt-get update -y sudo apt-get upgrade -y -sudo apt-get install $eth +heading "Installing ethereum" +sudo apt-get install -y $eth +heading "Updating eth-netstats client" cd ~/bin/www git pull sudo npm update cd .. + +success "Ethereum was updated successfully" + +heading "Restarting processes" pm2 start processes.json From 111b4a1bb075728137edd1199227d8eaf742b99d Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 04:48:45 +0300 Subject: [PATCH 4/5] updated processes.json, added app.json for non ec2 instances --- app.json | 21 +++++++++++++++++++++ bin/build.sh | 2 +- processes.json => processes-ec2.json | 0 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app.json rename processes.json => processes-ec2.json (100%) diff --git a/app.json b/app.json new file mode 100644 index 0000000..c0d4e41 --- /dev/null +++ b/app.json @@ -0,0 +1,21 @@ +[ + { + "name" : "node-app", + "cwd" : "/home/ubuntu/bin/www/", + "script" : "app.js", + "log_date_format" : "YYYY-MM-DD HH:mm Z", + "merge_logs" : false, + "watch" : false, + "exec_interpreter" : "node", + "exec_mode" : "fork_mode", + "env": + { + "NODE_ENV" : "production", + "RPC_HOST" : "localhost", + "RPC_PORT" : "8080", + "INSTANCE_NAME" : "", + "WS_SERVER" : "wss://eth-netstats.herokuapp.com", + "WS_SECRET" : "eth-net-stats-has-a-secret", + } + } +] \ No newline at end of file diff --git a/bin/build.sh b/bin/build.sh index 0a96b62..8624f10 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -78,7 +78,7 @@ cd ~/bin cd www git pull -[[ ! -f ~/bin/processes.json ]] && cp -b ./processes.json ./.. +[[ ! -f ~/bin/processes.json ]] && cp -b ./processes-ec2.json ./../processes.json npm install sudo npm install pm2 -g diff --git a/processes.json b/processes-ec2.json similarity index 100% rename from processes.json rename to processes-ec2.json From 76b80a3ddbf19e79b3aff22e7bbcdad28183f10d Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 04:51:19 +0300 Subject: [PATCH 5/5] fixed latency --- lib/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node.js b/lib/node.js index e93a84e..83c676a 100644 --- a/lib/node.js +++ b/lib/node.js @@ -112,7 +112,7 @@ function Node() console.warn('We are scheduling a reconnect operation', opts); }) .on('node-pong', function(data) { - var latency = (new Date()).getTime() - self._latency; + var latency = Math.ceil(((new Date()).getTime() - self._latency)/2); socket.emit('latency', { id: self.id, latency: latency }); }) .on('data', function incoming(data) {