This commit is contained in:
zhoujunhao 2018-10-10 15:44:02 +08:00
commit 5c37eb6b9c
3 changed files with 13 additions and 9 deletions

View File

@ -57,6 +57,7 @@ func CreateCleanManager() (*Manager, error) {
//Start start clean
func (t *Manager) Start(errchan chan error) error {
logrus.Info("CleanManager is starting.")
run := func() {
err := util.Exec(t.ctx, func() error {
now := time.Now()

View File

@ -38,6 +38,7 @@ type Config struct {
MQAPI string
DockerEndpoint string
HostIP string
CleanUp bool
}
//Builder builder server
@ -69,6 +70,7 @@ func (a *Builder) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&a.RunMode, "run", "sync", "sync data when worker start")
fs.StringVar(&a.DockerEndpoint, "dockerd", "127.0.0.1:2376", "dockerd endpoint")
fs.StringVar(&a.HostIP, "hostIP", "", "Current node Intranet IP")
fs.BoolVar(&a.CleanUp, "clean-up", false, "Turn on build version cleanup")
}
//SetLog 设置log

View File

@ -35,10 +35,10 @@ import (
"github.com/Sirupsen/logrus"
"github.com/goodrain/rainbond/builder/api"
"github.com/goodrain/rainbond/builder/clean"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
discoverv2 "github.com/goodrain/rainbond/discover.v2"
"github.com/goodrain/rainbond/builder/clean"
)
//Run start run
@ -75,15 +75,16 @@ func Run(s *option.Builder) error {
}
defer dis.Stop()
cle, err := clean.CreateCleanManager()
if err != nil {
return err
if s.Config.CleanUp {
cle, err := clean.CreateCleanManager()
if err != nil {
return err
}
if err := cle.Start(errChan); err != nil {
return err
}
defer cle.Stop()
}
if err := cle.Start(errChan); err != nil {
return err
}
defer cle.Stop()
keepalive, err := discoverv2.CreateKeepAlive(s.Config.EtcdEndPoints, "builder",
"", s.Config.HostIP, s.Config.APIPort)
if err != nil {