diff --git a/cmd/barak/main.go b/cmd/barak/main.go index d705e32e3..f363e04fc 100644 --- a/cmd/barak/main.go +++ b/cmd/barak/main.go @@ -155,9 +155,14 @@ func RunProcess(wait bool, label string, execPath string, args []string, input s } // Otherwise, create one. - proc := pcm.Create(pcm.ProcessModeDaemon, label, execPath, args, input) - barak.processes[label] = proc + proc, err := pcm.Create(pcm.ProcessModeDaemon, label, execPath, args, input) + if err == nil { + barak.processes[label] = proc + } barak.mtx.Unlock() + if err != nil { + return nil, err + } if wait { exitErr := pcm.Wait(proc) @@ -183,6 +188,7 @@ func StopProcess(label string, kill bool) (*ResponseStopProcess, error) { func ListProcesses() (*ResponseListProcesses, error) { var procs = []*pcm.Process{} barak.mtx.Lock() + fmt.Println("Processes: %v", barak.processes) for _, proc := range barak.processes { procs = append(procs, proc) } diff --git a/cmd/debora/commands.go b/cmd/debora/commands.go index a8bc64a3b..8929e85f8 100644 --- a/cmd/debora/commands.go +++ b/cmd/debora/commands.go @@ -9,6 +9,11 @@ import ( "github.com/tendermint/tendermint/rpc" ) +// These are convenience functions for a single developer. +// When multiple are involved, the workflow is different. +// (First the command(s) are signed by all validators, +// and then it is broadcast). + func RunProcess(privKey acm.PrivKey, remote string, command btypes.CommandRunProcess) (response btypes.ResponseRunProcess, err error) { nonce, err := GetNonce(remote) if err != nil { diff --git a/cmd/debora/main.go b/cmd/debora/main.go index 66c5a81ad..ef9d56409 100644 --- a/cmd/debora/main.go +++ b/cmd/debora/main.go @@ -26,6 +26,15 @@ var ( Value: "privkey", Usage: "file containing private key json", } + waitFlag = cli.BoolFlag{ + Name: "wait", + Usage: "whether to wait for termination", + } + inputFlag = cli.StringFlag{ + Name: "input", + Value: "", + Usage: "input to the program (e.g. stdin)", + } ) func main() { @@ -48,9 +57,9 @@ func main() { Name: "run", Usage: "run process", Action: cliRunProcess, - Flags: []cli.Flag{ - //remotesFlag, - //privKeyFlag, + Flags: []cli.Flag{ + waitFlag, + inputFlag, }, }, cli.Command{ @@ -81,7 +90,8 @@ func ParseFlags(c *cli.Context) (remotes []string, privKey acm.PrivKey) { privkeyFile := c.String("privkey-file") privkeyJSONBytes, err := ioutil.ReadFile(privkeyFile) if err != nil { - Exit(Fmt("Failed to read privkey from file %v. %v", privkeyFile, err)) + fmt.Printf("Failed to read privkey from file %v. %v", privkeyFile, err) + return remotes, nil } binary.ReadJSON(&privKey, privkeyJSONBytes, &err) if err != nil { @@ -91,14 +101,20 @@ func ParseFlags(c *cli.Context) (remotes []string, privKey acm.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{} + args := c.Args() + if len(args) < 2 { + Exit("Must specify