add -version support to beaconchain app

Signed-off-by: Leo Chen <leo@harmony.one>
pull/129/head
Leo Chen 6 years ago
parent 08c0fcdf9c
commit 782e01ffe8
  1. 1
      go_executable_build.sh
  2. 22
      runbeacon/run-beacon.go

@ -2,6 +2,7 @@
declare -A SRC declare -A SRC
SRC[benchmark]=benchmark.go SRC[benchmark]=benchmark.go
SRC[txgen]=client/txgen/main.go SRC[txgen]=client/txgen/main.go
SRC[beacon]=runbeacon/run-beacon.go
BINDIR=bin BINDIR=bin
BUCKET=unique-bucket-bin BUCKET=unique-bucket-bin

@ -2,15 +2,37 @@ package main
import ( import (
"flag" "flag"
"fmt"
"os"
"path"
"github.com/harmony-one/harmony/beaconchain" "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() { func main() {
numShards := flag.Int("numShards", 1, "number of shards of identity chain") numShards := flag.Int("numShards", 1, "number of shards of identity chain")
ip := flag.String("ip", "127.0.0.1", "ip on which beaconchain listens") ip := flag.String("ip", "127.0.0.1", "ip on which beaconchain listens")
port := flag.String("port", "8081", "port on which beaconchain listens") port := flag.String("port", "8081", "port on which beaconchain listens")
versionFlag := flag.Bool("version", false, "Output version info")
flag.Parse() flag.Parse()
if *versionFlag {
printVersion(os.Args[0])
}
bc := beaconchain.New(*numShards, *ip, *port) bc := beaconchain.New(*numShards, *ip, *port)
bc.StartServer() bc.StartServer()
} }

Loading…
Cancel
Save