func (p *Pod) processAcis() ([]schema.RuntimeApp, error) { apps := make([]schema.RuntimeApp, len(p.manifest.Pod.Apps)) errors := make([]error, len(p.manifest.Pod.Apps)) var wg sync.WaitGroup for i, e := range p.manifest.Pod.Apps { wg.Add(1) f := func(i int, e common.RuntimeApp) { defer wg.Done() app, err := p.processAci(e) if app != nil { apps[i] = *app } errors[i] = err } if !p.args.ParallelBuild { f(i, e) } else { go f(i, e) } } wg.Wait() failed := 0 for _, err := range errors { if err != nil { failed++ } } if failed > 0 { return apps, errs.With("Acis process failed").WithErrs(errors...) } return apps, nil }
func (e *envMap) Set(s string) error { if e.mapping == nil { e.mapping = make(map[string]string) } pair := strings.SplitN(s, "=", 2) if len(pair) != 2 { return errs.With("environment variable must be specified as name=value") } e.mapping[pair[0]] = pair[1] return nil }
func (x *CheckExec) Init(s *Service) error { if err := x.CheckCommon.CommonInit(s); err != nil { return err } if len(x.Command) == 0 { return errs.With("Exec command type require a command") } x.fields = x.fields.WithField("command", x.Command) return nil }
func (s *Service) Disable(doneWaiter *sync.WaitGroup, shutdown bool) { start := time.Now() logs.WithF(s.fields).Info("Disabling service") defer doneWaiter.Done() s.forceEnable = false s.disabled = errs.With("Service is disabled") s.runNotify() if len(s.DisableShutdownCommand) > 0 && shutdown { logs.WithF(s.fields).Debug("Run disableShutdown command") if err := ExecCommand(s.DisableShutdownCommand, s.DisableShutdownMaxDurationInMilli); err != nil { logs.WithEF(err, s.fields).Error("Shutdown result") s.nerve.execFailureCount.WithLabelValues(s.Name, s.Host, strconv.Itoa(s.Port), "disable-shutdown").Inc() } } if len(s.DisableGracefullyDoneCommand) > 0 { for { var err error if err = ExecCommand(s.DisableGracefullyDoneCommand, s.DisableGracefullyDoneIntervalInMilli); err == nil { logs.WithF(s.fields).Debug("Gracefull check succeed") break } s.nerve.execFailureCount.WithLabelValues(s.Name, s.Host, strconv.Itoa(s.Port), "disable-grace").Inc() logs.WithEF(err, s.fields).Debug("Gracefull check command fail") select { case <-time.After(start.Add(time.Duration(s.DisableMaxDurationInMilli) * time.Millisecond).Sub(time.Now())): logs.WithEF(err, s.fields).Warn("Disable max duration reached") return case <-time.After(time.Duration(s.DisableGracefullyDoneIntervalInMilli) * time.Millisecond): } } } time.Sleep(start.Add(time.Duration(s.DisableMinDurationInMilli) * time.Millisecond).Sub(time.Now())) }
func (p *Pod) CleanAndTry() error { return errs.With("Not implemented") }
func (p *Pod) Init() error { return errs.With("Pod init is not implemented yet") }