|
|
@ -9,9 +9,25 @@ import ( |
|
|
|
|
|
|
|
acm "github.com/tendermint/tendermint/account" |
|
|
|
"github.com/tendermint/tendermint/binary" |
|
|
|
btypes "github.com/tendermint/tendermint/cmd/barak/types" |
|
|
|
. "github.com/tendermint/tendermint/common" |
|
|
|
) |
|
|
|
|
|
|
|
var ( |
|
|
|
remotes []string |
|
|
|
privKey acm.PrivKey |
|
|
|
remotesFlag = cli.StringFlag{ |
|
|
|
Name: "remotes", |
|
|
|
Value: "http://127.0.0.1:8082", |
|
|
|
Usage: "comma separated list of remote baraks", |
|
|
|
} |
|
|
|
privKeyFlag = cli.StringFlag{ |
|
|
|
Name: "privkey-file", |
|
|
|
Value: "privkey", |
|
|
|
Usage: "file containing private key json", |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
func main() { |
|
|
|
fmt.Printf("New Debora Process (PID: %d)\n", os.Getpid()) |
|
|
|
app := cli.NewApp() |
|
|
@ -19,34 +35,46 @@ func main() { |
|
|
|
app.Usage = "summons commands to barak" |
|
|
|
app.Version = "0.0.1" |
|
|
|
app.Email = "ethan@erisindustries.com,jae@tendermint.com" |
|
|
|
app.Flags = []cli.Flag{} |
|
|
|
app.Flags = []cli.Flag{ |
|
|
|
remotesFlag, |
|
|
|
privKeyFlag, |
|
|
|
} |
|
|
|
app.Before = func(c *cli.Context) error { |
|
|
|
remotes, privKey = ParseFlags(c) |
|
|
|
return nil |
|
|
|
} |
|
|
|
app.Commands = []cli.Command{ |
|
|
|
cli.Command{ |
|
|
|
Name: "run", |
|
|
|
Usage: "run process", |
|
|
|
Action: cliRunProcess, |
|
|
|
Flags: []cli.Flag{ |
|
|
|
//remotesFlag,
|
|
|
|
//privKeyFlag,
|
|
|
|
}, |
|
|
|
}, |
|
|
|
cli.Command{ |
|
|
|
Name: "stop", |
|
|
|
Usage: "stop process", |
|
|
|
Action: cliStopProcess, |
|
|
|
Flags: []cli.Flag{ |
|
|
|
//remotesFlag,
|
|
|
|
//privKeyFlag,
|
|
|
|
}, |
|
|
|
}, |
|
|
|
cli.Command{ |
|
|
|
Name: "list", |
|
|
|
Usage: "list processes", |
|
|
|
Action: cliListProcesses, |
|
|
|
Flags: []cli.Flag{ |
|
|
|
remotesFlag, |
|
|
|
privKeyFlag, |
|
|
|
Flags: []cli.Flag{ |
|
|
|
//remotesFlag,
|
|
|
|
//privKeyFlag,
|
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
app.Run(os.Args) |
|
|
|
} |
|
|
|
|
|
|
|
var ( |
|
|
|
remotesFlag = cli.StringFlag{ |
|
|
|
Name: "remotes", |
|
|
|
Value: "http://127.0.0.1:8082", |
|
|
|
Usage: "comma separated list of remote baraks", |
|
|
|
} |
|
|
|
privKeyFlag = cli.StringFlag{ |
|
|
|
Name: "privkey-file", |
|
|
|
Value: "privkey", |
|
|
|
Usage: "file containing private key json", |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
func ParseFlags(c *cli.Context) (remotes []string, privKey acm.PrivKey) { |
|
|
|
remotesStr := c.String("remotes") |
|
|
|
remotes = strings.Split(remotesStr, ",") |
|
|
@ -62,8 +90,45 @@ func ParseFlags(c *cli.Context) (remotes []string, privKey acm.PrivKey) { |
|
|
|
return remotes, privKey |
|
|
|
} |
|
|
|
|
|
|
|
func cliRunProcess(c *cli.Context) { |
|
|
|
/* |
|
|
|
args := c.Args() |
|
|
|
if len(args) == 0 { |
|
|
|
log.Fatal("Must specify application name") |
|
|
|
} |
|
|
|
app := args[0] |
|
|
|
*/ |
|
|
|
command := btypes.CommandRunProcess{} |
|
|
|
for _, remote := range remotes { |
|
|
|
response, err := RunProcess(privKey, remote, command) |
|
|
|
if err != nil { |
|
|
|
fmt.Printf("%v failure. %v\n", remote, err) |
|
|
|
} else { |
|
|
|
fmt.Printf("%v success. %v\n", remote, response) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func cliStopProcess(c *cli.Context) { |
|
|
|
/* |
|
|
|
args := c.Args() |
|
|
|
if len(args) == 0 { |
|
|
|
log.Fatal("Must specify application name") |
|
|
|
} |
|
|
|
app := args[0] |
|
|
|
*/ |
|
|
|
command := btypes.CommandStopProcess{} |
|
|
|
for _, remote := range remotes { |
|
|
|
response, err := StopProcess(privKey, remote, command) |
|
|
|
if err != nil { |
|
|
|
fmt.Printf("%v failure. %v\n", remote, err) |
|
|
|
} else { |
|
|
|
fmt.Printf("%v success. %v\n", remote, response) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func cliListProcesses(c *cli.Context) { |
|
|
|
remotes, privKey := ParseFlags(c) |
|
|
|
/* |
|
|
|
args := c.Args() |
|
|
|
if len(args) == 0 { |
|
|
@ -71,12 +136,13 @@ func cliListProcesses(c *cli.Context) { |
|
|
|
} |
|
|
|
app := args[0] |
|
|
|
*/ |
|
|
|
command := btypes.CommandListProcesses{} |
|
|
|
for _, remote := range remotes { |
|
|
|
response, err := ListProcesses(privKey, remote) |
|
|
|
response, err := ListProcesses(privKey, remote, command) |
|
|
|
if err != nil { |
|
|
|
fmt.Printf("%v failed. %v\n", remote, err) |
|
|
|
fmt.Printf("%v failure. %v\n", remote, err) |
|
|
|
} else { |
|
|
|
fmt.Printf("%v processes: %v\n", remote, response.Processes) |
|
|
|
fmt.Printf("%v success: %v\n", remote, response) |
|
|
|
} |
|
|
|
} |
|
|
|
} |