diff --git a/bin/build-go.sh b/bin/build-go.sh index 1a66ea2..61a70d5 100644 --- a/bin/build-go.sh +++ b/bin/build-go.sh @@ -3,7 +3,7 @@ # update repository & install dependencies sudo apt-get update -y sudo apt-get upgrade -y -sudo apt-get install -y git mercurial build-essential software-properties-common wget pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev nodejs npm +sudo apt-get install -y git mercurial build-essential software-properties-common wget pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev nodejs npm ntp # add ethereum repos sudo add-apt-repository -y ppa:ethereum/ethereum-qt @@ -29,3 +29,12 @@ npm install npm install pm2 -g cp -b ./processes-go.json ./../processes.json + +# set up time update cronjob +cat > /etc/cron.hourly/ntpdate << EOF +#!/bin/sh +sudo service ntp stop +sudo ntpdate -s ntp.ubuntu.com +sudo service ntp start +EOF +sudo chmod 755 /etc/cron.hourly/ntpdate diff --git a/bin/build.sh b/bin/build.sh index cefe98f..d0f4f53 100644 --- a/bin/build.sh +++ b/bin/build.sh @@ -16,7 +16,7 @@ sudo add-apt-repository -y ppa:ethereum/ethereum-dev sudo apt-get -y update sudo apt-get -y upgrade -sudo apt-get -y install build-essential g++-4.8 git cmake libboost-all-dev automake unzip libgmp-dev libtool libleveldb-dev yasm libminiupnpc-dev libreadline-dev scons libncurses5-dev libcurl4-openssl-dev wget qtbase5-dev qt5-default qtdeclarative5-dev libqt5webkit5-dev libcryptopp-dev libjson-rpc-cpp-dev libmicrohttpd-dev libjsoncpp-dev libargtable2-dev clang-3.5 lldb-3.5 nodejs npm +sudo apt-get -y install build-essential g++-4.8 git cmake libboost-all-dev automake unzip libgmp-dev libtool libleveldb-dev yasm libminiupnpc-dev libreadline-dev scons libncurses5-dev libcurl4-openssl-dev wget qtbase5-dev qt5-default qtdeclarative5-dev libqt5webkit5-dev libcryptopp-dev libjson-rpc-cpp-dev libmicrohttpd-dev libjsoncpp-dev libargtable2-dev clang-3.5 lldb-3.5 nodejs npm ntp # add node symlink sudo ln -s /usr/bin/nodejs /usr/bin/node @@ -55,3 +55,11 @@ npm install npm install pm2 -g cp -b ./processes.json ./.. +# set up time update cronjob +cat > /etc/cron.hourly/ntpdate << EOF +#!/bin/sh +sudo service ntp stop +sudo ntpdate -s ntp.ubuntu.com +sudo service ntp start +EOF +sudo chmod 755 /etc/cron.hourly/ntpdate diff --git a/bin/eth.sh b/bin/eth.sh index 6bd399b..14bc8ae 100644 --- a/bin/eth.sh +++ b/bin/eth.sh @@ -2,7 +2,7 @@ trap "exit" INT if [ -f /usr/bin/ethereum ] then - ethereum -rpc true + geth --rpc true else eth -x 15 -l 30303 -n off -m off -v 1 -j fi \ No newline at end of file diff --git a/lib/node.js b/lib/node.js index cea4b4c..71b5b41 100644 --- a/lib/node.js +++ b/lib/node.js @@ -100,7 +100,7 @@ function Node() console.error('Socket connection closed'); }) .on('error', function error(err) { - console.error(err); + console.error("socket:", err); }) .on('reconnecting', function reconnecting(opts) { console.warn('We are scheduling a reconnect operation', opts); @@ -143,7 +143,7 @@ Node.prototype.isActive = function() code: '1', msg: err }); - console.error(err); + console.error("peerCount:", err); } this.stats.active = false; @@ -177,13 +177,13 @@ Node.prototype.getBlock = function(number) code: '3', msg: err }); - console.error(err); + console.error("blockNumber:", err); } } try { block = web3.eth.getBlock(number, true); - block.arrival = Date.now(); + block.arrival = (new Date()).getTime(); block.propagation = block.arrival - (block.timestamp * 1000); if(block.hash != '?' && typeof block.difficulty !== 'undefined') @@ -196,7 +196,7 @@ Node.prototype.getBlock = function(number) code: '2', msg: err }); - console.error(err); + console.error("getBlock:", err); } return block; @@ -310,7 +310,7 @@ Node.prototype.getStats = function() try { this.stats.pending = web3.eth.getBlockTransactionCount('pending'); } catch (err) { - console.error(err); + console.error("getBlockTransactionCount('pending'):", err); } this.stats.mining = web3.eth.mining; this.stats.gasPrice = web3.eth.gasPrice.toString(10); @@ -392,7 +392,7 @@ Node.prototype.emit = function(message, payload) socket.emit(message, payload); } catch (err) { - console.error(err); + console.error("socket.emit:", err); } } } diff --git a/processes.json b/processes.json index c6489b0..875130f 100644 --- a/processes.json +++ b/processes.json @@ -3,10 +3,11 @@ "name" : "eth", "cwd" : "/home/ubuntu/bin/www/", "script" : "bin/eth.sh", + "log_date_format" : "YYYY-MM-DD HH:mm Z", "log_file" : "/home/ubuntu/logs/eth-log.log", "out_file" : "/home/ubuntu/logs/eth-out.log", "error_file" : "/home/ubuntu/logs/eth-err.log", - "merge_logs" : true, + "merge_logs" : false, "watch" : false, "cron_restart" : "0 0 * * *", "exec_interpreter" : "bash", @@ -21,7 +22,6 @@ "error_file" : "/home/ubuntu/logs/node-app-err.log", "merge_logs" : true, "watch" : false, - // "cron_restart" : "0 0 * * *", "exec_interpreter" : "node", "exec_mode" : "fork_mode", "env":