github.com/jenkins-x/jx/v2@v2.1.155/pkg/helm/tiller.go (about) 1 package helm 2 3 import ( 4 "os" 5 "path/filepath" 6 7 "github.com/jenkins-x/jx-logging/pkg/log" 8 "github.com/jenkins-x/jx/v2/pkg/util" 9 "github.com/pkg/errors" 10 ) 11 12 // GetTillerAddress returns the address that tiller is listening on 13 func GetTillerAddress() string { 14 tillerAddress := os.Getenv("TILLER_ADDR") 15 if tillerAddress == "" { 16 tillerAddress = ":44134" 17 } 18 return tillerAddress 19 } 20 21 // StartLocalTiller starts local tiller server 22 func StartLocalTiller(lazy bool) error { 23 tillerAddress := GetTillerAddress() 24 tillerArgs := os.Getenv("TILLER_ARGS") 25 args := []string{"-listen", tillerAddress, "-alsologtostderr"} 26 if tillerArgs != "" { 27 args = append(args, tillerArgs) 28 } 29 logsDir, err := util.LogsDir() 30 if err != nil { 31 return err 32 } 33 logFile := filepath.Join(logsDir, "tiller.log") 34 f, err := os.Create(logFile) 35 if err != nil { 36 return errors.Wrapf(err, "Failed to create tiller log file %s: %s", logFile, err) 37 } 38 err = util.RunCommandBackground("tiller", f, !lazy, args...) 39 if err == nil { 40 log.Logger().Infof("running tiller locally and logging to file: %s", util.ColorInfo(logFile)) 41 } else if lazy { 42 // lets assume its because the process is already running so lets ignore 43 return nil 44 } 45 return err 46 } 47 48 // RestartLocalTiller resttarts locall tiller 49 func RestartLocalTiller() error { 50 log.Logger().Info("checking if we need to kill a local tiller process") 51 err := util.KillProcesses("tiller") 52 if err != nil { 53 return errors.Wrap(err, "unable to kill local tiller process") 54 } 55 return StartLocalTiller(false) 56 } 57 58 // StartLocalTillerIfNotRunning starts local tiller if not running 59 func StartLocalTillerIfNotRunning() error { 60 return StartLocalTiller(true) 61 }