diff --git a/cli/src/alluxio.org/cli/env/env.go b/cli/src/alluxio.org/cli/env/env.go index f0327a64808d..df423daebe0f 100644 --- a/cli/src/alluxio.org/cli/env/env.go +++ b/cli/src/alluxio.org/cli/env/env.go @@ -221,7 +221,7 @@ func checkAndSetJava(envVar *viper.Viper) error { // check if java is available via `PATH` using `which` whichJavaPath, err := exec.Command("which", "java").Output() if err == nil { - envVar.Set(ConfJava.EnvVar, string(whichJavaPath)) + envVar.Set(ConfJava.EnvVar, strings.TrimSpace(string(whichJavaPath))) return nil } // cannot find java diff --git a/cli/src/alluxio.org/cli/env/process_start.go b/cli/src/alluxio.org/cli/env/process_start.go index 5d58d291adf6..5dada82d69a9 100644 --- a/cli/src/alluxio.org/cli/env/process_start.go +++ b/cli/src/alluxio.org/cli/env/process_start.go @@ -16,13 +16,15 @@ import ( ) type StartProcessCommand struct { + Name string AsyncStart bool SkipKillOnStart bool } func (c *StartProcessCommand) ToCommand() *cobra.Command { + c.Name = "start" cmd := &cobra.Command{ - Use: "start", + Use: c.Name, Short: "Starts a process", } cmd.PersistentFlags().BoolVarP(&c.SkipKillOnStart, "skip-kill-prev", "N", false, "Avoid killing previous running processes when starting") diff --git a/cli/src/alluxio.org/cli/env/process_stop.go b/cli/src/alluxio.org/cli/env/process_stop.go index 3b4c1554d319..13a586376702 100644 --- a/cli/src/alluxio.org/cli/env/process_stop.go +++ b/cli/src/alluxio.org/cli/env/process_stop.go @@ -14,12 +14,14 @@ package env import "github.com/spf13/cobra" type StopProcessCommand struct { + Name string SoftKill bool } func (c *StopProcessCommand) ToCommand() *cobra.Command { + c.Name = "stop" cmd := &cobra.Command{ - Use: "stop", + Use: c.Name, Short: "Stops a process", } cmd.PersistentFlags().BoolVarP(&c.SoftKill, "soft", "s", false, "Soft kill only, don't forcibly kill the process") diff --git a/cli/src/alluxio.org/cli/main.go b/cli/src/alluxio.org/cli/main.go index 1e135e32994a..cd97fb2be122 100644 --- a/cli/src/alluxio.org/cli/main.go +++ b/cli/src/alluxio.org/cli/main.go @@ -34,11 +34,18 @@ import ( func main() { for _, p := range []env.Process{ + processes.All, processes.JobMaster, + processes.JobMasters, processes.JobWorker, + processes.JobWorkers, + processes.Local, processes.Master, + processes.Masters, processes.Proxy, + processes.Proxies, processes.Worker, + processes.Workers, } { env.RegisterProcess(p) } diff --git a/cli/src/alluxio.org/cli/processes/all.go b/cli/src/alluxio.org/cli/processes/all.go new file mode 100644 index 000000000000..32a42557a71e --- /dev/null +++ b/cli/src/alluxio.org/cli/processes/all.go @@ -0,0 +1,76 @@ +/* + * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 + * (the "License"). You may not use this work except in compliance with the License, which is + * available at www.apache.org/licenses/LICENSE-2.0 + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied, as more fully set forth in the License. + * + * See the NOTICE file distributed with this work for information regarding copyright ownership. + */ + +package processes + +import ( + "github.com/palantir/stacktrace" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "alluxio.org/cli/env" +) + +var All = &AllProcess{ + BaseProcess: &env.BaseProcess{ + Name: "all", + }, + Processes: []env.Process{ + Masters, + JobMasters, + Workers, + JobWorkers, + Proxies, + }, +} + +type AllProcess struct { + *env.BaseProcess + Processes []env.Process +} + +func (p *AllProcess) SetEnvVars(envVar *viper.Viper) { + return +} + +func (p *AllProcess) Base() *env.BaseProcess { + return p.BaseProcess +} + +func (p *AllProcess) StartCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *AllProcess) StopCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *AllProcess) Start(cmd *env.StartProcessCommand) error { + for i := 0; i < len(p.Processes); i++ { + subProcess := p.Processes[i] + if err := subProcess.Start(cmd); err != nil { + return stacktrace.Propagate(err, "Error starting subprocesses for %s", p.Processes[i]) + } + } + return nil +} + +func (p *AllProcess) Stop(cmd *env.StopProcessCommand) error { + for i := len(p.Processes) - 1; i >= 0; i-- { + subProcess := p.Processes[i] + if err := subProcess.Stop(cmd); err != nil { + return stacktrace.Propagate(err, "Error stopping subprocesses for %s", p.Processes[i]) + } + } + return nil +} diff --git a/cli/src/alluxio.org/cli/processes/common.go b/cli/src/alluxio.org/cli/processes/common.go new file mode 100644 index 000000000000..3035585c4a48 --- /dev/null +++ b/cli/src/alluxio.org/cli/processes/common.go @@ -0,0 +1,280 @@ +/* + * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 + * (the "License"). You may not use this work except in compliance with the License, which is + * available at www.apache.org/licenses/LICENSE-2.0 + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied, as more fully set forth in the License. + * + * See the NOTICE file distributed with this work for information regarding copyright ownership. + */ + +package processes + +import ( + "fmt" + "io" + "io/ioutil" + "net" + "os" + "os/user" + "path/filepath" + "strings" + "sync" + "time" + + "github.com/palantir/stacktrace" + "golang.org/x/crypto/ssh" + + "alluxio.org/cli/env" + "alluxio.org/log" +) + +type Result struct { + err error + msg string +} + +type HostnamesFile struct { + Name string + Mutex *sync.Mutex + Once *sync.Once + Hostnames []string +} + +func NewHostnamesFile(name string) *HostnamesFile { + return &HostnamesFile{ + Name: name, + Mutex: &sync.Mutex{}, + Once: &sync.Once{}, + } +} + +// for each node, create a client and run +func runCommand(command string, mode string) error { + // prepare client config, ssh port info + config, port, err := prepareCommand() + if err != nil { + return stacktrace.Propagate(err, "prepare command failed") + } + + // get list of masters or workers, or both + hosts, err := getHostnames(mode) + if err != nil { + return stacktrace.Propagate(err, "cannot read host names") + } + + // create wait group and channels + var wg sync.WaitGroup + results := make(chan Result) + for _, h := range hosts { + wg.Add(1) + host := h + + go func() { + defer wg.Done() + // dial on target remote address with given host, config and ssh port + dialAddr := fmt.Sprintf("%s:%d", host, port) + conn, err := ssh.Dial("tcp", dialAddr, config) + if err != nil { + result := Result{ + err: err, + msg: fmt.Sprintf("dial failed to %v", host), + } + results <- result + } + defer func(conn *ssh.Client) { + if err := conn.Close(); err != nil { + log.Logger.Infof("connection to %s closed, error: %s", host, err) + } else { + log.Logger.Infof("connection to %s closed", host) + } + }(conn) + + // create and set up a session + session, err := conn.NewSession() + if err != nil { + result := Result{ + err: err, + msg: fmt.Sprintf("cannot create session at %v.", host), + } + results <- result + } + defer func(session *ssh.Session) { + err := session.Close() + if err != nil && err != io.EOF { + log.Logger.Infof("session at %s closed, error: %s", host, err) + } else { + log.Logger.Infof("session at %s closed", host) + } + }(session) + + session.Stdout = os.Stdout + session.Stderr = os.Stderr + + // run command on the session, output errors + if err = session.Run(command); err != nil { + result := Result{ + err: err, + msg: fmt.Sprintf("run command %v failed at %v", command, host), + } + results <- result + } + + // if no errors, return nil + result := Result{ + err: nil, + msg: "", + } + results <- result + }() + } + + go func() { + wg.Wait() + close(results) + }() + + return errorHandler(command, hosts, results) +} + +func prepareCommand() (*ssh.ClientConfig, int, error) { + // get the current user + cu, err := user.Current() + if err != nil { + return nil, 0, stacktrace.Propagate(err, "cannot find current user") + } + cuName := cu.Username + log.Logger.Debugf("current user: %v", cuName) + + // get public key + signer, err := getSigner() + if err != nil { + return nil, 0, stacktrace.Propagate(err, "cannot get private key") + } + + // find default ssh port + port, e := net.LookupPort("tcp", "ssh") + if e != nil { + return nil, 0, stacktrace.Propagate(err, "cannot find default ssh port") + } + + // set client config with current user and signer + config := &ssh.ClientConfig{ + User: cuName, + Auth: []ssh.AuthMethod{ + ssh.PublicKeys(signer), + }, + Timeout: 5 * time.Second, + HostKeyCallback: ssh.InsecureIgnoreHostKey(), + } + return config, port, nil +} + +func addStartFlags(argument string, cmd *env.StartProcessCommand) string { + cliPath := filepath.Join(env.Env.EnvVar.GetString(env.ConfAlluxioHome.EnvVar), "bin", "alluxio") + var command []string + command = append(command, cliPath, argument) + if cmd.AsyncStart { + command = append(command, "-a") + } + if cmd.SkipKillOnStart { + command = append(command, "-N") + } + return strings.Join(command, " ") +} + +func addStopFlags(argument string, cmd *env.StopProcessCommand) string { + cliPath := filepath.Join(env.Env.EnvVar.GetString(env.ConfAlluxioHome.EnvVar), "bin", "alluxio") + var command []string + command = append(command, cliPath, argument) + if cmd.SoftKill { + command = append(command, "-s") + } + return strings.Join(command, " ") +} + +func getHostnames(mode string) ([]string, error) { + if mode != "master" && mode != "worker" && mode != "all" { + return nil, stacktrace.NewError("invalid mode for readHostnames, " + + "available readHostnames modes: [master, worker, all]") + } + var hosts []string + if mode == "master" || mode == "all" { + masterList, err := NewHostnamesFile("masters").getHostnames() + if err != nil { + return nil, stacktrace.Propagate(err, "cannot get masters") + } + hosts = append(hosts, masterList...) + } + if mode == "worker" || mode == "all" { + workerList, err := NewHostnamesFile("worker").getHostnames() + if err != nil { + return nil, stacktrace.Propagate(err, "cannot get workers") + } + hosts = append(hosts, workerList...) + } + return hosts, nil +} + +func (f *HostnamesFile) getHostnames() ([]string, error) { + f.Mutex.Lock() + defer f.Mutex.Unlock() + var parseErr error + f.Once.Do(func() { + p := filepath.Join(env.Env.EnvVar.GetString(env.ConfAlluxioConfDir.EnvVar), f.Name) + file, err := ioutil.ReadFile(p) + if err != nil { + parseErr = err + } + for _, line := range strings.Split(string(file), "\n") { + if strings.HasPrefix(strings.TrimSpace(line), "#") { + continue + } + if strings.TrimSpace(line) != "" { + f.Hostnames = append(f.Hostnames, line) + } + } + }) + if parseErr != nil { + return nil, stacktrace.Propagate(parseErr, "error parsing hostnames file") + } + return f.Hostnames, nil +} + +func getSigner() (ssh.Signer, error) { + // get private key + homePath, err := os.UserHomeDir() + if err != nil { + return nil, stacktrace.Propagate(err, "user home directory not found at %v", homePath) + } + privateKeyFile := filepath.Join(homePath, ".ssh", "id_rsa") + privateKey, err := os.ReadFile(privateKeyFile) + if err != nil { + return nil, stacktrace.Propagate(err, "private key file not found at %v", privateKeyFile) + } + parsedPrivateKey, err := ssh.ParsePrivateKey(privateKey) + if err != nil { + return nil, stacktrace.Propagate(err, "cannot parse public key at %v", privateKeyFile) + } + return parsedPrivateKey, nil +} + +func errorHandler(command string, nodes []string, results chan Result) error { + hasError := 0 + for result := range results { + if result.err != nil { + hasError++ + err := stacktrace.Propagate(result.err, result.msg) + if err != nil { + return err + } + } + } + + if hasError != 0 { + return stacktrace.NewError("run command %s failed, number of failures: %s", command, hasError) + } + log.Logger.Infof("run command %s successful on nodes: %s", command, nodes) + return nil +} diff --git a/cli/src/alluxio.org/cli/processes/job_masters.go b/cli/src/alluxio.org/cli/processes/job_masters.go new file mode 100644 index 000000000000..d84b338b45c0 --- /dev/null +++ b/cli/src/alluxio.org/cli/processes/job_masters.go @@ -0,0 +1,59 @@ +/* + * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 + * (the "License"). You may not use this work except in compliance with the License, which is + * available at www.apache.org/licenses/LICENSE-2.0 + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied, as more fully set forth in the License. + * + * See the NOTICE file distributed with this work for information regarding copyright ownership. + */ + +package processes + +import ( + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "alluxio.org/cli/env" +) + +var JobMasters = &JobMastersProcess{ + BaseProcess: &env.BaseProcess{ + Name: "job_masters", + }, +} + +type JobMastersProcess struct { + *env.BaseProcess +} + +func (p *JobMastersProcess) SetEnvVars(envVar *viper.Viper) { + return +} + +func (p *JobMastersProcess) Base() *env.BaseProcess { + return p.BaseProcess +} + +func (p *JobMastersProcess) StartCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *JobMastersProcess) StopCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *JobMastersProcess) Start(cmd *env.StartProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, JobMasterProcess{}.Name}, " ") + return runCommand(addStartFlags(arguments, cmd), "master") +} + +func (p *JobMastersProcess) Stop(cmd *env.StopProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, JobMasterProcess{}.Name}, " ") + return runCommand(addStopFlags(arguments, cmd), "master") +} diff --git a/cli/src/alluxio.org/cli/processes/job_workers.go b/cli/src/alluxio.org/cli/processes/job_workers.go new file mode 100644 index 000000000000..dc6dbf47be93 --- /dev/null +++ b/cli/src/alluxio.org/cli/processes/job_workers.go @@ -0,0 +1,59 @@ +/* + * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 + * (the "License"). You may not use this work except in compliance with the License, which is + * available at www.apache.org/licenses/LICENSE-2.0 + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied, as more fully set forth in the License. + * + * See the NOTICE file distributed with this work for information regarding copyright ownership. + */ + +package processes + +import ( + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "alluxio.org/cli/env" +) + +var JobWorkers = &JobWorkersProcess{ + BaseProcess: &env.BaseProcess{ + Name: "job_workers", + }, +} + +type JobWorkersProcess struct { + *env.BaseProcess +} + +func (p *JobWorkersProcess) SetEnvVars(envVar *viper.Viper) { + return +} + +func (p *JobWorkersProcess) Base() *env.BaseProcess { + return p.BaseProcess +} + +func (p *JobWorkersProcess) StartCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *JobWorkersProcess) StopCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *JobWorkersProcess) Start(cmd *env.StartProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, JobWorkerProcess{}.Name}, " ") + return runCommand(addStartFlags(arguments, cmd), "worker") +} + +func (p *JobWorkersProcess) Stop(cmd *env.StopProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, JobWorkerProcess{}.Name}, " ") + return runCommand(addStopFlags(arguments, cmd), "worker") +} diff --git a/cli/src/alluxio.org/cli/processes/local.go b/cli/src/alluxio.org/cli/processes/local.go new file mode 100644 index 000000000000..2aa2b6e108ca --- /dev/null +++ b/cli/src/alluxio.org/cli/processes/local.go @@ -0,0 +1,76 @@ +/* + * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 + * (the "License"). You may not use this work except in compliance with the License, which is + * available at www.apache.org/licenses/LICENSE-2.0 + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied, as more fully set forth in the License. + * + * See the NOTICE file distributed with this work for information regarding copyright ownership. + */ + +package processes + +import ( + "github.com/palantir/stacktrace" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "alluxio.org/cli/env" +) + +var Local = &LocalProcess{ + BaseProcess: &env.BaseProcess{ + Name: "local", + }, + Processes: []env.Process{ + Master, + JobMaster, + Worker, + JobWorker, + Proxy, + }, +} + +type LocalProcess struct { + *env.BaseProcess + Processes []env.Process +} + +func (p *LocalProcess) SetEnvVars(envVar *viper.Viper) { + return +} + +func (p *LocalProcess) Base() *env.BaseProcess { + return p.BaseProcess +} + +func (p *LocalProcess) StartCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *LocalProcess) StopCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *LocalProcess) Start(cmd *env.StartProcessCommand) error { + for i := 0; i < len(p.Processes); i++ { + subProcess := p.Processes[i] + if err := subProcess.Start(cmd); err != nil { + return stacktrace.Propagate(err, "Error starting subprocesses for %s", p.Processes[i]) + } + } + return nil +} + +func (p *LocalProcess) Stop(cmd *env.StopProcessCommand) error { + for i := len(p.Processes) - 1; i >= 0; i-- { + subProcess := p.Processes[i] + if err := subProcess.Stop(cmd); err != nil { + return stacktrace.Propagate(err, "Error stopping subprocesses for %s", p.Processes[i]) + } + } + return nil +} diff --git a/cli/src/alluxio.org/cli/processes/masters.go b/cli/src/alluxio.org/cli/processes/masters.go new file mode 100644 index 000000000000..bf6c375d7573 --- /dev/null +++ b/cli/src/alluxio.org/cli/processes/masters.go @@ -0,0 +1,59 @@ +/* + * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 + * (the "License"). You may not use this work except in compliance with the License, which is + * available at www.apache.org/licenses/LICENSE-2.0 + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied, as more fully set forth in the License. + * + * See the NOTICE file distributed with this work for information regarding copyright ownership. + */ + +package processes + +import ( + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "alluxio.org/cli/env" +) + +var Masters = &MastersProcess{ + BaseProcess: &env.BaseProcess{ + Name: "masters", + }, +} + +type MastersProcess struct { + *env.BaseProcess +} + +func (p *MastersProcess) SetEnvVars(envVar *viper.Viper) { + return +} + +func (p *MastersProcess) Base() *env.BaseProcess { + return p.BaseProcess +} + +func (p *MastersProcess) StartCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *MastersProcess) StopCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *MastersProcess) Start(cmd *env.StartProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, MasterProcess{}.Name}, " ") + return runCommand(addStartFlags(arguments, cmd), "master") +} + +func (p *MastersProcess) Stop(cmd *env.StopProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, MasterProcess{}.Name}, " ") + return runCommand(addStopFlags(arguments, cmd), "master") +} diff --git a/cli/src/alluxio.org/cli/processes/proxies.go b/cli/src/alluxio.org/cli/processes/proxies.go new file mode 100644 index 000000000000..a925e1b70dff --- /dev/null +++ b/cli/src/alluxio.org/cli/processes/proxies.go @@ -0,0 +1,59 @@ +/* + * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 + * (the "License"). You may not use this work except in compliance with the License, which is + * available at www.apache.org/licenses/LICENSE-2.0 + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied, as more fully set forth in the License. + * + * See the NOTICE file distributed with this work for information regarding copyright ownership. + */ + +package processes + +import ( + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "alluxio.org/cli/env" +) + +var Proxies = &ProxiesProcess{ + BaseProcess: &env.BaseProcess{ + Name: "proxies", + }, +} + +type ProxiesProcess struct { + *env.BaseProcess +} + +func (p *ProxiesProcess) SetEnvVars(envVar *viper.Viper) { + return +} + +func (p *ProxiesProcess) Base() *env.BaseProcess { + return p.BaseProcess +} + +func (p *ProxiesProcess) StartCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *ProxiesProcess) StopCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *ProxiesProcess) Start(cmd *env.StartProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, ProxyProcess{}.Name}, " ") + return runCommand(addStartFlags(arguments, cmd), "all") +} + +func (p *ProxiesProcess) Stop(cmd *env.StopProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, ProxyProcess{}.Name}, " ") + return runCommand(addStopFlags(arguments, cmd), "all") +} diff --git a/cli/src/alluxio.org/cli/processes/workers.go b/cli/src/alluxio.org/cli/processes/workers.go new file mode 100644 index 000000000000..5a7944efc8ad --- /dev/null +++ b/cli/src/alluxio.org/cli/processes/workers.go @@ -0,0 +1,59 @@ +/* + * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 + * (the "License"). You may not use this work except in compliance with the License, which is + * available at www.apache.org/licenses/LICENSE-2.0 + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied, as more fully set forth in the License. + * + * See the NOTICE file distributed with this work for information regarding copyright ownership. + */ + +package processes + +import ( + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "alluxio.org/cli/env" +) + +var Workers = &WorkersProcess{ + BaseProcess: &env.BaseProcess{ + Name: "workers", + }, +} + +type WorkersProcess struct { + *env.BaseProcess +} + +func (p *WorkersProcess) SetEnvVars(envVar *viper.Viper) { + return +} + +func (p *WorkersProcess) Base() *env.BaseProcess { + return p.BaseProcess +} + +func (p *WorkersProcess) StartCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *WorkersProcess) StopCmd(cmd *cobra.Command) *cobra.Command { + cmd.Use = p.Name + return cmd +} + +func (p *WorkersProcess) Start(cmd *env.StartProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, WorkerProcess{}.Name}, " ") + return runCommand(addStartFlags(arguments, cmd), "worker") +} + +func (p *WorkersProcess) Stop(cmd *env.StopProcessCommand) error { + arguments := strings.Join([]string{env.Service{}.Name, cmd.Name, WorkerProcess{}.Name}, " ") + return runCommand(addStopFlags(arguments, cmd), "worker") +} diff --git a/cli/src/alluxio.org/go.mod b/cli/src/alluxio.org/go.mod index f7bce5da94af..958b996eb25a 100644 --- a/cli/src/alluxio.org/go.mod +++ b/cli/src/alluxio.org/go.mod @@ -8,6 +8,7 @@ require ( github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.15.0 + golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e ) require ( diff --git a/cli/src/alluxio.org/go.sum b/cli/src/alluxio.org/go.sum index 1fe712a31c23..c364d69e05c6 100644 --- a/cli/src/alluxio.org/go.sum +++ b/cli/src/alluxio.org/go.sum @@ -205,6 +205,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -328,6 +330,7 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=