From 782e01ffe81266e98ba69532d9e36b9805d42b98 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 1 Dec 2018 20:23:32 -0800 Subject: [PATCH 1/3] add -version support to beaconchain app Signed-off-by: Leo Chen --- go_executable_build.sh | 1 + runbeacon/run-beacon.go | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/go_executable_build.sh b/go_executable_build.sh index a6a3fa482..a5e2ca340 100755 --- a/go_executable_build.sh +++ b/go_executable_build.sh @@ -2,6 +2,7 @@ declare -A SRC SRC[benchmark]=benchmark.go SRC[txgen]=client/txgen/main.go +SRC[beacon]=runbeacon/run-beacon.go BINDIR=bin BUCKET=unique-bucket-bin diff --git a/runbeacon/run-beacon.go b/runbeacon/run-beacon.go index 39a366cc9..42739dc40 100644 --- a/runbeacon/run-beacon.go +++ b/runbeacon/run-beacon.go @@ -2,15 +2,37 @@ package main import ( "flag" + "fmt" + "os" + "path" "github.com/harmony-one/harmony/beaconchain" ) +var ( + version string + builtBy string + builtAt string + commit string +) + +func printVersion(me string) { + fmt.Fprintf(os.Stderr, "Harmony (C) 2018. %v, version %v-%v (%v %v)\n", path.Base(me), version, commit, builtBy, builtAt) + os.Exit(0) +} + func main() { numShards := flag.Int("numShards", 1, "number of shards of identity chain") ip := flag.String("ip", "127.0.0.1", "ip on which beaconchain listens") port := flag.String("port", "8081", "port on which beaconchain listens") + versionFlag := flag.Bool("version", false, "Output version info") + flag.Parse() + + if *versionFlag { + printVersion(os.Args[0]) + } + bc := beaconchain.New(*numShards, *ip, *port) bc.StartServer() } From 43fc3dae5f3948c1ac7e4d3ec89a3dde3e77c67c Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 1 Dec 2018 20:46:31 -0800 Subject: [PATCH 2/3] support beacon chain in local test use ./deploy.sh -p local_config1.txt Signed-off-by: Leo Chen --- deploy.sh | 11 ++++++++++- kill_node.sh | 4 +++- local_config1.txt | 12 ++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 local_config1.txt diff --git a/deploy.sh b/deploy.sh index f2acde193..4d3a6a0c8 100755 --- a/deploy.sh +++ b/deploy.sh @@ -61,6 +61,7 @@ fi # Also it's recommended to use `go build` for testing the whole exe. go build -o bin/benchmark go build -o bin/txgen client/txgen/main.go +go build -o bin/beacon runbeacon/run-beacon.go # Create a tmp folder for logs t=`date +"%Y%m%d-%H%M%S"` @@ -68,6 +69,11 @@ log_folder="tmp_log/log-$t" mkdir -p $log_folder +if [ -n "$PEER" ]; then + ./bin/beacon > $log_folder/beacon.log 2>&1 & + sleep 1 #wait or beachchain up +fi + # Start nodes while IFS='' read -r line || [[ -n "$line" ]]; do IFS=' ' read ip port mode shardID <<< $line @@ -77,7 +83,7 @@ while IFS='' read -r line || [[ -n "$line" ]]; do ./bin/benchmark -ip $ip -port $port -config_file $config -log_folder $log_folder $DB -min_peers $MIN & else ./bin/benchmark -ip $ip -port $port -log_folder $log_folder $DB $PEER -min_peers $MIN & - sleep 5 + sleep 1 fi fi done < $config @@ -85,3 +91,6 @@ done < $config if [ "$TXGEN" == "true" ]; then ./bin/txgen -config_file $config -log_folder $log_folder -duration $DURATION fi + +# Kill nodes if any +./kill_node.sh diff --git a/kill_node.sh b/kill_node.sh index 1f6d9e4bd..da969d300 100755 --- a/kill_node.sh +++ b/kill_node.sh @@ -1,4 +1,6 @@ -for pid in `/bin/ps -fu $USER| grep "benchmark\|txgen\|soldier\|commander\|profiler" | grep -v "grep" | awk '{print $2}'`; +#!/bin/bash + +for pid in `/bin/ps -fu $USER| grep "benchmark\|txgen\|soldier\|commander\|profiler\|beacon" | grep -v "grep" | grep -v "vi" | awk '{print $2}'`; do echo 'Killed process: '$pid kill -9 $pid diff --git a/local_config1.txt b/local_config1.txt new file mode 100644 index 000000000..a6b607074 --- /dev/null +++ b/local_config1.txt @@ -0,0 +1,12 @@ +127.0.0.1 9000 leader 0 +127.0.0.1 9001 validator 0 +127.0.0.1 9002 validator 0 +127.0.0.1 9003 validator 0 +127.0.0.1 9004 validator 0 +127.0.0.1 9005 validator 0 +127.0.0.1 9006 validator 0 +127.0.0.1 9007 validator 0 +127.0.0.1 9008 validator 0 +127.0.0.1 9009 validator 0 +127.0.0.1 9010 validator 0 +127.0.0.1 9999 client 0 From 6f319f25adf9690013b8c66eb595810d5846050d Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 1 Dec 2018 21:01:21 -0800 Subject: [PATCH 3/3] ignore local logs Signed-off-by: Leo Chen --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 4686834ed..951de7ccf 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ keystore # Cscope files cscope.* + +# local runtime logs +tmp_log