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