diff --git a/cmd/barak/main.go b/cmd/barak/main.go index 0c70b4f8e..92315ae53 100644 --- a/cmd/barak/main.go +++ b/cmd/barak/main.go @@ -86,7 +86,7 @@ func Run(authCommand AuthCommand) (interface{}, error) { if err != nil { return nil, err } - log.Info(Fmt("Run() received command %v:\n%v", reflect.TypeOf(command), command)) + log.Info(Fmt("Run() received command %v:%v", reflect.TypeOf(command), command)) // Issue command switch c := command.(type) { case CommandStartProcess: @@ -162,7 +162,7 @@ func StartProcess(wait bool, label string, execPath string, args []string, input if wait { <-proc.WaitCh output := pcm.ReadOutput(proc) - fmt.Println("Read output", output) + // fmt.Println("Read output", output) if proc.ExitState == nil { return &ResponseStartProcess{ Success: true, diff --git a/cmd/debora/main.go b/cmd/debora/main.go index 6f0357864..801acb797 100644 --- a/cmd/debora/main.go +++ b/cmd/debora/main.go @@ -145,12 +145,14 @@ func cliGetStatus(c *cli.Context) { fmt.Println("BTW, status takes no arguments.") } wg := sync.WaitGroup{} + failed := 0 for _, remote := range Config.Remotes { wg.Add(1) go func(remote string) { defer wg.Done() response, err := GetStatus(remote) if err != nil { + failed++ fmt.Printf("%v failure. %v\n", remote, err) } else { fmt.Printf("%v success. %v\n", remote, response) @@ -158,6 +160,9 @@ func cliGetStatus(c *cli.Context) { }(remote) } wg.Wait() + if 0 < failed { + os.Exit(1) + } } func cliStartProcess(c *cli.Context) { @@ -175,12 +180,14 @@ func cliStartProcess(c *cli.Context) { Input: c.String("input"), } wg := sync.WaitGroup{} + failed := 0 for _, remote := range Config.Remotes { wg.Add(1) go func(remote string) { defer wg.Done() response, err := StartProcess(Config.PrivKey, remote, command) if err != nil { + failed++ fmt.Printf("%v failure. %v\n", remote, err) } else { fmt.Printf("%v success.\n", remote) @@ -195,6 +202,9 @@ func cliStartProcess(c *cli.Context) { }(remote) } wg.Wait() + if 0 < failed { + os.Exit(1) + } } func cliStopProcess(c *cli.Context) { @@ -208,12 +218,14 @@ func cliStopProcess(c *cli.Context) { Kill: true, } wg := sync.WaitGroup{} + failed := 0 for _, remote := range Config.Remotes { wg.Add(1) go func(remote string) { defer wg.Done() response, err := StopProcess(Config.PrivKey, remote, command) if err != nil { + failed++ fmt.Printf("%v failure. %v\n", remote, err) } else { fmt.Printf("%v success. %v\n", remote, response) @@ -221,6 +233,9 @@ func cliStopProcess(c *cli.Context) { }(remote) } wg.Wait() + if 0 < failed { + os.Exit(1) + } } func cliListProcesses(c *cli.Context) { @@ -233,12 +248,14 @@ func cliListProcesses(c *cli.Context) { */ command := btypes.CommandListProcesses{} wg := sync.WaitGroup{} + failed := 0 for _, remote := range Config.Remotes { wg.Add(1) go func(remote string) { defer wg.Done() response, err := ListProcesses(Config.PrivKey, remote, command) if err != nil { + failed++ fmt.Printf("%v failure. %v\n", Blue(remote), Red(err)) } else { fmt.Printf("%v processes:\n", Blue(remote)) @@ -257,6 +274,9 @@ func cliListProcesses(c *cli.Context) { }(remote) } wg.Wait() + if 0 < failed { + os.Exit(1) + } } func cliOpenListener(c *cli.Context) { @@ -269,12 +289,14 @@ func cliOpenListener(c *cli.Context) { Addr: listenAddr, } wg := sync.WaitGroup{} + failed := 0 for _, remote := range Config.Remotes { wg.Add(1) go func(remote string) { defer wg.Done() response, err := OpenListener(Config.PrivKey, remote, command) if err != nil { + failed++ fmt.Printf("%v failure. %v\n", remote, err) } else { fmt.Printf("%v opened %v.\n", remote, response.Addr) @@ -282,6 +304,9 @@ func cliOpenListener(c *cli.Context) { }(remote) } wg.Wait() + if 0 < failed { + os.Exit(1) + } } func cliCloseListener(c *cli.Context) { @@ -294,12 +319,14 @@ func cliCloseListener(c *cli.Context) { Addr: listenAddr, } wg := sync.WaitGroup{} + failed := 0 for _, remote := range Config.Remotes { wg.Add(1) go func(remote string) { defer wg.Done() response, err := CloseListener(Config.PrivKey, remote, command) if err != nil { + failed++ fmt.Printf("%v failure. %v\n", remote, err) } else { fmt.Printf("%v success. %v\n", remote, response) @@ -307,6 +334,9 @@ func cliCloseListener(c *cli.Context) { }(remote) } wg.Wait() + if 0 < failed { + os.Exit(1) + } } func cliDownloadFile(c *cli.Context) { @@ -321,12 +351,14 @@ func cliDownloadFile(c *cli.Context) { } wg := sync.WaitGroup{} + failed := 0 for _, remote := range Config.Remotes { wg.Add(1) go func(remote string, localPath string) { defer wg.Done() n, err := DownloadFile(Config.PrivKey, remote, command, localPath) if err != nil { + failed++ fmt.Printf("%v failure. %v\n", remote, err) } else { fmt.Printf("%v success. Wrote %v bytes to %v\n", remote, n, localPath) @@ -334,17 +366,22 @@ func cliDownloadFile(c *cli.Context) { }(remote, Fmt("%v_%v", localPathPrefix, remoteNick(remote))) } wg.Wait() + if 0 < failed { + os.Exit(1) + } } func cliQuit(c *cli.Context) { command := btypes.CommandQuit{} wg := sync.WaitGroup{} + failed := 0 for _, remote := range Config.Remotes { wg.Add(1) go func(remote string) { defer wg.Done() response, err := Quit(Config.PrivKey, remote, command) if err != nil { + failed++ fmt.Printf("%v failure. %v\n", remote, err) } else { fmt.Printf("%v success. %v\n", remote, response) @@ -352,4 +389,7 @@ func cliQuit(c *cli.Context) { }(remote) } wg.Wait() + if 0 < failed { + os.Exit(1) + } } diff --git a/scripts/unsafe_debug_net.sh b/scripts/unsafe_debug_net.sh index c8816d0d1..8c9d10a1e 100755 --- a/scripts/unsafe_debug_net.sh +++ b/scripts/unsafe_debug_net.sh @@ -1,10 +1,12 @@ -#!/bin/sh +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' debora run -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; killall tendermint" debora run -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; tendermint unsafe_reset_priv_validator; rm -rf ~/.tendermint/data" debora run -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; git pull origin develop; make" debora run --bg --label tendermint -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; tendermint node" -echo "sleeping for a minute" +printf "\n\nSleeping for a minute" sleep 60 debora download tendermint "logs/async$1" debora run -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; killall tendermint" diff --git a/scripts/unsafe_upgrade_barak.sh b/scripts/unsafe_upgrade_barak.sh index be0abbb14..897124cc3 100755 --- a/scripts/unsafe_upgrade_barak.sh +++ b/scripts/unsafe_upgrade_barak.sh @@ -1,15 +1,18 @@ -#!/bin/sh +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' debora open "[::]:46661" -debora --group default.upgrade list # TODO replace with command to test with -echo "Will shut down barak default port..." -sleep 10 +debora --group default.upgrade status +printf "\n\nWill shut down barak default port..." +sleep 3 debora --group default.upgrade close "[::]:46660" debora --group default.upgrade run -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; git pull origin develop; make" debora --group default.upgrade run -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; mkdir -p ~/.barak/logs" debora --group default.upgrade run --bg --label barak -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; barak --config=cmd/barak/seed | stdinwriter -outpath ~/.barak/logs/barak.log" -echo "Testing new barak..." -debora list -sleep 10 -echo "Will shut down old barak..." +printf "\n\nTesting new barak..." +debora status +sleep 3 +printf "\n\nWill shut down old barak..." debora --group default.upgrade quit +printf "Done!"