Skip to content
Permalink
Browse files

add consul, consul watch to update code

  • Loading branch information...
thanhson1085 committed Nov 24, 2018
1 parent b3c0819 commit 3e72abf28c8ea064d842a87a698b322a9472bdda
Showing with 23 additions and 6 deletions.
  1. +1 −4 Vagrantfile.main
  2. +5 −1 Vagrantfile.node
  3. +17 −1 reset.sh
@@ -49,16 +49,13 @@ Vagrant.configure('2') do |config|
cd ${HOME}/go/src/github.com/ethereum/ && git clone https://github.com/tomochain/tomochain.git go-ethereum
cd ${HOME}/go/src/github.com/ethereum/go-ethereum && make all
cd /tmp && wget https://releases.hashicorp.com/consul/1.4.0/consul_1.4.0_linux_amd64.zip && unzip consul_1.4.0_linux_amd64.zip && chmod +x consul && mv consul /usr/bin/consul
curl -sSL https://get.docker.com/ | sh
export HOST_IP=`ifconfig | grep 'inet' | grep -v inet6 | grep -v '127.0.0.1' | grep -v 'broadcast 172.17.255.255' | awk '{ print $2}'`
docker swarm init --advertise-addr ${HOST_IP}
cd /tmp && wget https://releases.hashicorp.com/consul/1.4.0/consul_1.4.0_linux_amd64.zip && unzip consul_1.4.0_linux_amd64.zip && chmod +x consul && mv consul /usr/bin/consul
nohup consul agent -bind=${HOST_IP} -client=0.0.0.0 -node=tomochain -ui -data-dir=/tmp/consul -server -dev<&- &>/vagrant/consul.log &
nohup consul watch -http-addr=${HOST_IP}:8500 -type=key -key=tomochain/reset "cd /vagrant && bash reset.sh"<&- &>/vagrant/consul_watch.log &
cd /vagrant
nohup bash ./main.sh<&- &>/vagrant/node.log &
source .env && docker stack deploy -c app.yml localnet
@@ -49,7 +49,7 @@ Vagrant.configure('2') do |config|
config.vm.provision "file", source: sshKeysFile, destination: "/vagrant/.sshKeys"

config.vm.provision "shell", inline: <<-SHELL
apt-get update && apt-get install -y build-essential git wget
apt-get update && apt-get install -y build-essential git wget unzip
wget https://dl.google.com/go/go1.11.1.linux-amd64.tar.gz && tar -xvf go1.11.1.linux-amd64.tar.gz && mv go /usr/local
export PATH=$PATH:/usr/local/go/bin
echo "export PATH=$PATH:/usr/local/go/bin" >> /root/.bashrc
@@ -63,6 +63,10 @@ Vagrant.configure('2') do |config|
(crontab -u root -l; echo "*/10 * * * * bash /vagrant/vote.sh >> /vagrant/vote.log 2>&1" ) | crontab -u root -
(crontab -u root -l; echo "*/15 * * * * bash /vagrant/unvote.sh >> /vagrant/unvote.log 2>&1" ) | crontab -u root -
cd /tmp && wget https://releases.hashicorp.com/consul/1.4.0/consul_1.4.0_linux_amd64.zip && unzip consul_1.4.0_linux_amd64.zip && chmod +x consul && mv consul /usr/bin/consul
cd /vagrant && source .env
nohup consul watch -http-addr=${MAIN_IP}:8500 -type=key -key=tomochain/reset "bash reset.sh"<&- &>/vagrant/consul_watch.log &
cd /vagrant
nohup bash ./node.sh<&- &>/vagrant/node.log &
@@ -1,4 +1,20 @@
#!/bin/bash

PROJECT_DIR="${HOME}/go/src/github.com/ethereum/go-ethereum"
cd ${PROJECT_DIR} && git pull origin master && make all
DATE_WITH_TIME=`date "+%Y%m%d-%H%M%S"`
cd ${PROJECT_DIR}

LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})

echo Local $LOCAL Base $BASE Remote $REMOTE
if [ $LOCAL != $REMOTE ] && [ $LOCAL == $BASE ]; then
echo "Stop node!"
pkill -f "bin/tomo"
git pull origin master && make all
echo "Restart it!"
cd /vagrant && nohup bash ./node.sh<&- &>/vagrant/node.reset.${DATE_WITH_TIME}.log &
else
echo "Nothing to do!!!"
fi

0 comments on commit 3e72abf

Please sign in to comment.
You can’t perform that action at this time.