package cmd import ( "fmt" "path/filepath" "git.apinb.com/bsm-sdk/engine/env" "github.com/gookit/goutil/cliutil" ) func getFilePath(srv *Service) (binPath, logsPath string) { binPath = filepath.Join(env.MeshEnv.Prefix, srv.ServiceKey) logsPath = filepath.Join(env.MeshEnv.Prefix, "logs", srv.ServiceKey+"@"+srv.Version+".log") return } func (srv *Service) Start() { bin, log := getFilePath(srv) cmd := "chmod +x " + bin _, err := cliutil.ShellExec(cmd) checkError(err) //nohup ./passport >log/passport.log & cmd = "nohup " + bin + " > " + log + " 2>&1 &" out, err := cliutil.ShellExec(cmd) checkError(err) fmt.Println(string(out)) } func (srv *Service) Stop() { bin, _ := getFilePath(srv) //killall -9 passport /usr/local/bsm/passport cmd := "-9 " + srv.ServiceKey + " " + bin out, err := cliutil.ExecCmd("killall", cliutil.StringToOSArgs(cmd), env.MeshEnv.Prefix) if err != nil { fmt.Printf("stop error:%s\n", err) } else { fmt.Println(out) } } func (srv *Service) Restart() { srv.Stop() srv.Start() }