Crazy colors for Debora
This commit is contained in:
parent
aa931f88ab
commit
5e70769117
|
@ -76,8 +76,8 @@ func (bcR *BlockchainReactor) Start(sw *p2p.Switch) {
|
|||
if atomic.CompareAndSwapUint32(&bcR.running, 0, 1) {
|
||||
log.Info("Starting BlockchainReactor")
|
||||
bcR.sw = sw
|
||||
bcR.pool.Start()
|
||||
if bcR.sync {
|
||||
bcR.pool.Start()
|
||||
go bcR.poolRoutine()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"github.com/codegangsta/cli"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
|
@ -26,14 +27,14 @@ func main() {
|
|||
}
|
||||
|
||||
var (
|
||||
configFlag = cli.StringFlag{
|
||||
Name: "config-file",
|
||||
Value: rootDir + "/config.json",
|
||||
Usage: "config file",
|
||||
groupFlag = cli.StringFlag{
|
||||
Name: "group",
|
||||
Value: "default",
|
||||
Usage: "uses ~/.debora/<group>.cfg",
|
||||
}
|
||||
waitFlag = cli.BoolFlag{
|
||||
Name: "wait",
|
||||
Usage: "whether to wait for termination",
|
||||
bgFlag = cli.BoolFlag{
|
||||
Name: "bg",
|
||||
Usage: "if set, runs as a background daemon",
|
||||
}
|
||||
inputFlag = cli.StringFlag{
|
||||
Name: "input",
|
||||
|
@ -48,10 +49,12 @@ func main() {
|
|||
app.Version = "0.0.1"
|
||||
app.Email = "ethan@erisindustries.com,jae@tendermint.com"
|
||||
app.Flags = []cli.Flag{
|
||||
configFlag,
|
||||
groupFlag,
|
||||
}
|
||||
app.Before = func(c *cli.Context) error {
|
||||
ReadConfig(c.String("config-file"))
|
||||
configFile := rootDir + "/" + c.String("group") + ".cfg"
|
||||
fmt.Printf("Using configuration from %v\n", configFile)
|
||||
ReadConfig(configFile)
|
||||
return nil
|
||||
}
|
||||
app.Commands = []cli.Command{
|
||||
|
@ -65,7 +68,7 @@ func main() {
|
|||
Usage: "run process",
|
||||
Action: cliRunProcess,
|
||||
Flags: []cli.Flag{
|
||||
waitFlag,
|
||||
bgFlag,
|
||||
inputFlag,
|
||||
},
|
||||
},
|
||||
|
@ -104,14 +107,20 @@ func cliGetStatus(c *cli.Context) {
|
|||
if len(args) != 0 {
|
||||
fmt.Println("BTW, status takes no arguments.")
|
||||
}
|
||||
wg := sync.WaitGroup{}
|
||||
for _, remote := range Config.Remotes {
|
||||
wg.Add(1)
|
||||
go func(remote string) {
|
||||
defer wg.Done()
|
||||
response, err := GetStatus(remote)
|
||||
if err != nil {
|
||||
fmt.Printf("%v failure. %v\n", remote, err)
|
||||
} else {
|
||||
fmt.Printf("%v success. %v\n", remote, response)
|
||||
}
|
||||
}(remote)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func cliRunProcess(c *cli.Context) {
|
||||
|
@ -123,13 +132,17 @@ func cliRunProcess(c *cli.Context) {
|
|||
execPath := args[1]
|
||||
args = args[2:]
|
||||
command := btypes.CommandRunProcess{
|
||||
Wait: c.Bool("wait"),
|
||||
Wait: !c.Bool("bg"),
|
||||
Label: label,
|
||||
ExecPath: execPath,
|
||||
Args: args,
|
||||
Input: c.String("input"),
|
||||
}
|
||||
wg := sync.WaitGroup{}
|
||||
for _, remote := range Config.Remotes {
|
||||
wg.Add(1)
|
||||
go func(remote string) {
|
||||
defer wg.Done()
|
||||
response, err := RunProcess(Config.PrivKey, remote, command)
|
||||
if err != nil {
|
||||
fmt.Printf("%v failure. %v\n", remote, err)
|
||||
|
@ -143,7 +156,9 @@ func cliRunProcess(c *cli.Context) {
|
|||
fmt.Println("(no output)")
|
||||
}
|
||||
}
|
||||
}(remote)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func cliStopProcess(c *cli.Context) {
|
||||
|
@ -156,14 +171,20 @@ func cliStopProcess(c *cli.Context) {
|
|||
Label: label,
|
||||
Kill: true,
|
||||
}
|
||||
wg := sync.WaitGroup{}
|
||||
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 {
|
||||
fmt.Printf("%v failure. %v\n", remote, err)
|
||||
} else {
|
||||
fmt.Printf("%v success. %v\n", remote, response)
|
||||
}
|
||||
}(remote)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func cliListProcesses(c *cli.Context) {
|
||||
|
@ -175,12 +196,16 @@ func cliListProcesses(c *cli.Context) {
|
|||
app := args[0]
|
||||
*/
|
||||
command := btypes.CommandListProcesses{}
|
||||
wg := sync.WaitGroup{}
|
||||
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 {
|
||||
fmt.Printf("%v failure. %v\n", remote, err)
|
||||
fmt.Printf("%v failure. %v\n", Blue(remote), Red(err))
|
||||
} else {
|
||||
fmt.Printf("%v processes:\n", remote)
|
||||
fmt.Printf("%v processes:\n", Blue(remote))
|
||||
for _, proc := range response.Processes {
|
||||
startTimeStr := Green(proc.StartTime.String())
|
||||
endTimeStr := proc.EndTime.String()
|
||||
|
@ -188,11 +213,13 @@ func cliListProcesses(c *cli.Context) {
|
|||
endTimeStr = Red(endTimeStr)
|
||||
}
|
||||
fmt.Printf(" %v start:%v end:%v output:%v\n",
|
||||
RightPadString(Fmt("\"%v\" => `%v` (%v)", proc.Label, proc.ExecPath, proc.Pid), 40),
|
||||
RightPadString(Fmt("\"%v\" => `%v` (%v)", Yellow(proc.Label), proc.ExecPath, proc.Pid), 40),
|
||||
startTimeStr, endTimeStr, proc.OutputPath)
|
||||
}
|
||||
}
|
||||
}(remote)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func cliDownloadFile(c *cli.Context) {
|
||||
|
@ -205,7 +232,11 @@ func cliDownloadFile(c *cli.Context) {
|
|||
command := btypes.CommandServeFile{
|
||||
Path: remotePath,
|
||||
}
|
||||
wg := sync.WaitGroup{}
|
||||
for i, remote := range Config.Remotes {
|
||||
wg.Add(1)
|
||||
go func(remote string) {
|
||||
defer wg.Done()
|
||||
localPath := Fmt("%v_%v", localPathPrefix, i)
|
||||
n, err := DownloadFile(Config.PrivKey, remote, command, localPath)
|
||||
if err != nil {
|
||||
|
@ -213,5 +244,7 @@ func cliDownloadFile(c *cli.Context) {
|
|||
} else {
|
||||
fmt.Printf("%v success. Wrote %v bytes to %v\n", remote, n, localPath)
|
||||
}
|
||||
}(remote)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ func Call(remote string, method string, params []interface{}, dest interface{})
|
|||
}
|
||||
requestBytes := binary.JSONBytes(request)
|
||||
requestBuf := bytes.NewBuffer(requestBytes)
|
||||
log.Debug(Fmt("RPC request to %v: %v", remote, string(requestBytes)))
|
||||
httpResponse, err := http.Post(remote, "text/json", requestBuf)
|
||||
if err != nil {
|
||||
return dest, err
|
||||
|
|
Loading…
Reference in New Issue