diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index 7bebc8941..7abd91ece 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -1355,10 +1355,24 @@ func NewBspawnCommand(stdin io.Reader, stdout, stderr io.Writer) *BspawnCommand // ParseFlags parses command line flags from args. func (cmd *BspawnCommand) ParseFlags(args []string) error { - if len(args) != 1 { + fs := flag.NewFlagSet("pilosactl", flag.ContinueOnError) + fs.SetOutput(ioutil.Discard) + creatorHosts := fs.String("creator.hosts", "", "") + creatorLFP := fs.String("creator.log-file-prefix", "", "") + pilosaHosts := fs.String("pilosa-hosts", "", "") + agentHosts := fs.String("agent-hosts", "", "") + sshUser := fs.String("ssh-user", "", "") + fs.BoolVar(&cmd.Human, "human", false, "") + fs.BoolVar(&cmd.CopyBinary, "copy-binary", false, "") + + err := fs.Parse(args) + if err != nil { + return err + } + if len(fs.Args()) != 1 { return flag.ErrHelp } - f, err := os.Open(args[0]) + f, err := os.Open(fs.Args()[0]) if err != nil { return err } @@ -1367,6 +1381,20 @@ func (cmd *BspawnCommand) ParseFlags(args []string) error { if err != nil { return err } + if *pilosaHosts != "" { + cmd.PilosaHosts = strings.Split(*pilosaHosts, ",") + } + if *agentHosts != "" { + cmd.AgentHosts = strings.Split(*agentHosts, ",") + } + if *sshUser != "" { + cmd.SSHUser = *sshUser + } + // TODO support all creator args - just checking for creatorHosts here won't be sufficient + if *creatorHosts != "" { + cmd.CreatorArgs = []string{"-hosts=" + *creatorHosts, "-log-file-prefix=" + *creatorLFP, "-ssh-user=" + cmd.SSHUser} + } + return nil } @@ -1377,7 +1405,30 @@ pilosactl bspawn is a tool for running multiple instances of bagent against a cl Usage: -pilosactl spawn configfile +pilosactl spawn [flags] configfile + +The following flags are allowed and will override the values in the config file: + + -creator.hosts + hosts argument for pilosactl create + + -creator.log-file-prefix + log-file-prefix argument for pilosactl create + + -pilosa-hosts + pilosa hosts to run against (will ignore creator args) + + -agent-hosts + hosts to use for benchmark agents + + -ssh-user + pilosa hosts to run against (will ignore creator args) + + -copy-binary + controls whether or not to build and copy pilosactl to agents + + -human + toggle human readable output (indented json with formatted times) `) } diff --git a/cmd/pilosactl/spawn.json b/cmd/pilosactl/spawn.json index deb5e355b..9ef3fd9e4 100644 --- a/cmd/pilosactl/spawn.json +++ b/cmd/pilosactl/spawn.json @@ -1,7 +1,7 @@ { "CreatorArgs": ["-hosts=localhost:19444,localhost:19445,localhost:19446", "-log-file-prefix", "asdfe"], "AgentHosts": [], - "Human": true, + "SSHUser": "nikolai-von-havlenhoken", "Benchmarks": [ { "Num": 3, diff --git a/pilosactl/ssh.go b/pilosactl/ssh.go index 4e6074157..b595dcd82 100644 --- a/pilosactl/ssh.go +++ b/pilosactl/ssh.go @@ -53,7 +53,7 @@ func NewSSH(host, username, keyfile string, stderr io.Writer) (*SSH, error) { client, err := ssh.Dial("tcp", host, config) if err != nil { - return nil, fmt.Errorf("NewSHH failed Dial: %v ", err) + return nil, fmt.Errorf("NewSHH failed Dial - host: %v, config: %v, err: %v ", host, config, err) } return &SSH{client: client, Stderr: stderr}, nil