From 0c6e6e4f4447f269d7108ba72bfa9a4b86a7a839 Mon Sep 17 00:00:00 2001 From: jaffee Date: Wed, 14 Dec 2016 15:05:50 -0600 Subject: [PATCH] creator can set GOMAXPROCS for remote pilosa nodes --- cmd/pilosactl/main.go | 8 ++++++++ creator/remote.go | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index a220212f0..68ff61cc0 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -985,6 +985,7 @@ type CreateCommand struct { ReplicaN int LogFilePrefix string Hosts []string + GoMaxProcs int SSHUser string @@ -1012,6 +1013,7 @@ func (cmd *CreateCommand) ParseFlags(args []string) error { fs.IntVar(&cmd.ReplicaN, "replicaN", 1, "") fs.StringVar(&cmd.LogFilePrefix, "log-file-prefix", "", "") var hosts string + fs.IntVar(&cmd.GoMaxProcs, "gomaxprocs", 0, "") fs.StringVar(&hosts, "hosts", "", "") fs.StringVar(&cmd.SSHUser, "ssh-user", "", "") @@ -1052,6 +1054,11 @@ The following flags are allowed: -ssh-user username to use when contacting remote hosts + + -gomaxprocs + when starting a cluster on remote hosts, this + will set the value of GOMAXPROCS. + `) } @@ -1077,6 +1084,7 @@ func (cmd *CreateCommand) Run(ctx context.Context) error { ReplicaN: cmd.ReplicaN, SSHUser: cmd.SSHUser, Stderr: cmd.Stderr, + GoMaxProcs: cmd.GoMaxProcs, } default: return fmt.Errorf("Unknown cluster type %v", cmd.Type) diff --git a/creator/remote.go b/creator/remote.go index 724b05459..dd8baa564 100644 --- a/creator/remote.go +++ b/creator/remote.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "net" + "strconv" "sync" "time" @@ -20,6 +21,7 @@ type RemoteCluster struct { SSHUser string Keyfile string Key []byte + GoMaxProcs int Stderr io.Writer wg *sync.WaitGroup logs []io.Reader @@ -113,7 +115,12 @@ func (c *RemoteCluster) Start() error { c.pipeWs = append(c.pipeWs, pipeW) c.stdins = append(c.stdins, inpipe) - err = sess.Start("pilosa -config " + configname) + gomaxprocsString := "" + if c.GoMaxProcs != 0 { + gomaxprocsString = "GOMAXPROCS=" + strconv.Itoa(c.GoMaxProcs) + " " + } + + err = sess.Start(gomaxprocsString + "pilosa -config " + configname) if err != nil { return err }