diff --git a/config.toml b/config.toml index a9a0b07..07db1f1 100644 --- a/config.toml +++ b/config.toml @@ -5,11 +5,11 @@ network = "cosmos" # RPC-Server [rpc] -address = "113.209.186.219:26657" +address = "localhost:26657" # Rest-server [rest_server] -address = "113.209.186.219:1317" +address = "localhost:1317" [validator_info] operatorAddress = "cosmosvaloper14l0fp639yudfl46zauvv8rkzjgd4u0zk2aseys" diff --git a/function/config/config.go b/function/config/config.go index 60c3d94..6b9f266 100644 --- a/function/config/config.go +++ b/function/config/config.go @@ -18,7 +18,7 @@ func Init() { var config = readConfig() - fmt.Printf("\033[7m##### %s #####\033[0m\n", config.Title) + fmt.Printf("\033[7m##### Exporter Start #####\033[0m\n\n") t.RpcServer = config.Rpc.Address t.RestServer = config.Rest_server.Address @@ -30,7 +30,7 @@ func Init() { t.OutputPrint = config.Option.OutputPrint t.Bech32MainPrefix = config.Network - fmt.Println("\n[ Your Info ]") + fmt.Println("\n[ Your Info]") fmt.Println("- Network:", config.Network) fmt.Println("- RPC Server Address:", config.Rpc.Address) fmt.Println("- Rest Server Address:", config.Rest_server.Address) @@ -69,16 +69,35 @@ func readConfig() t.Config { func serverChecker() { - fmt.Println("serverChecker") + fmt.Printf("RPC-Server Check..") + cmd := "curl -s -XGET " + t.RpcServer + "/abci_info" +" -H \"accept:application/json\"" + cmdRun := exec.Command("/bin/bash", "-c", cmd) + timer(cmdRun) - cmd := "curl -s -XGET " + t.RpcServer + "/abci_info" +" -H \"accept:application/json\"" - out, _ := exec.Command("/bin/bash", "-c", cmd).Output() - fmt.Println(string(out)) + fmt.Printf("Rest-Server Check..") cmd = "curl -s -XGET " + t.RestServer + "/node_info" +" -H \"accept:application/json\"" - out, _ = exec.Command("/bin/bash", "-c", cmd).Output() - fmt.Println(string(out)) + cmdRun = exec.Command("/bin/bash", "-c", cmd) + timer(cmdRun) +} + +func timer(cmdRun *exec.Cmd) { + + if err := cmdRun.Start(); err != nil { + log.Fatal(err) + } + + timer := time.AfterFunc(5 * time.Second, func() { + cmdRun.Process.Kill() + }) + if err := cmdRun.Wait(); err != nil { + fmt.Println("Failure!") + panic("Error !!!") + } else { + fmt.Println("Success!") + } + timer.Stop() } diff --git a/go.mod b/go.mod index 4affab8..3cf7bc9 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,6 @@ go 1.12 require ( github.com/BurntSushi/toml v0.3.1 - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.1 // indirect github.com/prometheus/client_golang v1.1.0 github.com/tendermint/tendermint v0.32.3 )