github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/hostinit/runner.go (about) 1 package hostinit 2 3 import ( 4 "time" 5 6 "github.com/evergreen-ci/evergreen" 7 "github.com/evergreen-ci/evergreen/model" 8 "github.com/mongodb/grip" 9 "github.com/pkg/errors" 10 ) 11 12 // Runner executes the hostinit process. 13 type Runner struct{} 14 15 const ( 16 RunnerName = "hostinit" 17 Description = "initialize new Evergreen hosts" 18 ) 19 20 func (r *Runner) Name() string { 21 return RunnerName 22 } 23 24 func (r *Runner) Description() string { 25 return Description 26 } 27 28 func (r *Runner) Run(config *evergreen.Settings) error { 29 startTime := time.Now() 30 grip.Infof("starting hostinit at time: %s", startTime) 31 32 init := &HostInit{config} 33 34 if err := init.setupReadyHosts(); err != nil { 35 err = errors.Wrap(err, "Error running hostinit") 36 grip.Error(err) 37 return err 38 } 39 40 runtime := time.Since(startTime) 41 if err := model.SetProcessRuntimeCompleted(RunnerName, runtime); err != nil { 42 grip.Errorf("Error updating process status: %+v", err) 43 } 44 grip.Infof("Hostinit took %s to run", runtime) 45 return nil 46 }