// Pause schedules the service instance as paused and returns the number of
// affected instances.
540933
func (l *ServiceListener) Pause(reqs []StateRequest) (int, bool) {
	delta := 0
	ok := true

	for _, req := range reqs {

		logger := plog.WithFields(log.Fields{
			"hostid":     req.HostID,
			"serviceid":  req.ServiceID,
			"instanceid": req.InstanceID,
		})

		// ONLY pause services with a desired state of run
		if err := UpdateState(l.conn, req, func(s *State) bool {
			if s.DesiredState == service.SVCRun {
				s.DesiredState = service.SVCPause
				return true
			}
			return false
		}); err != nil {

			logger.WithError(err).Warn("Could not pause service state")
			ok = false
			continue
		}
		delta++
	}

	return delta, ok
}
901569
func (tm *TrustMetric) Pause() {
	tm.mtx.Lock()
	defer tm.mtx.Unlock()

	// Pause the metric for now
	tm.paused = true
}
1198721
func (s *Server) Resume() {
	s.mu.Lock()
	defer s.mu.Unlock()
	s.shutdown = false
	for service := range s.statusMap {
		s.setServingStatusLocked(service, healthpb.HealthCheckResponse_SERVING)
	}
}
980715
func (uow *UnitOfWork) Pause() {
	for _, container := range uow.Targeted().Reversed() {
		container.Pause()
	}
}
775935
func (self *Logic) PauseRecover() {
	switch self.Status() {
	case status.PAUSE:
		self.setStatus(status.RUN)
	case status.RUN:
		self.setStatus(status.PAUSE)
	}

	scheduler.PauseRecover()
}
872439
func (c *chrono) Pause() {
	c.pausedAt = c.Now()
	c.paused = true
}
1306660
func (c *container) Pause() {
	if c.Running() {
		name := c.ActualName(false)
		fmt.Fprintf(c.CommandsOut(), "Pausing container %s ...\n", name)
		args := []string{"pause", name}
		executeCommand("docker", args, c.CommandsOut(), c.CommandsErr())
	}
}
248738
func (o *PauseOptions) RunPause() error {
	r := o.Builder().
		WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
		NamespaceParam(o.Namespace).DefaultNamespace().
		FilenameParam(o.EnforceNamespace, &o.FilenameOptions).
		ResourceTypeOrNameArgs(true, o.Resources...).
		ContinueOnError().
		Latest().
		Flatten().
		Do()
	if err := r.Err(); err != nil {
		return err
	}

	allErrs := []error{}
	infos, err := r.Infos()
	if err != nil {
		// restore previous command behavior where
		// an error caused by retrieving infos due to
		// at least a single broken object did not result
		// in an immediate return, but rather an overall
		// aggregation of errors.
		allErrs = append(allErrs, err)
	}

	for _, patch := range set.CalculatePatches(infos, scheme.DefaultJSONEncoder(), set.PatchFn(o.Pauser)) {
		info := patch.Info

		if patch.Err != nil {
			resourceString := info.Mapping.Resource.Resource
			if len(info.Mapping.Resource.Group) > 0 {
				resourceString = resourceString + "." + info.Mapping.Resource.Group
			}
			allErrs = append(allErrs, fmt.Errorf("error: %s %q %v", resourceString, info.Name, patch.Err))
			continue
		}

		if string(patch.Patch) == "{}" || len(patch.Patch) == 0 {
			printer, err := o.ToPrinter("already paused")
			if err != nil {
				allErrs = append(allErrs, err)
				continue
			}
			if err = printer.PrintObj(info.Object, o.Out); err != nil {
				allErrs = append(allErrs, err)
			}
			continue
		}

		obj, err := resource.NewHelper(info.Client, info.Mapping).Patch(info.Namespace, info.Name, types.StrategicMergePatchType, patch.Patch, nil)
		if err != nil {
			allErrs = append(allErrs, fmt.Errorf("failed to patch: %v", err))
			continue
		}

		info.Refresh(obj, true)
		printer, err := o.ToPrinter("paused")
		if err != nil {
			allErrs = append(allErrs, err)
			continue
		}
		if err = printer.PrintObj(info.Object, o.Out); err != nil {
			allErrs = append(allErrs, err)
		}
	}

	return utilerrors.NewAggregate(allErrs)
}
1078161
func (c *Container) Pause(ctx context.Context) error {
	if !c.container.State.Paused {
		if err := c.client.ContainerPause(ctx, c.container.ID); err != nil {
			return err
		}
		return c.updateInnerContainer(ctx)
	}
	return nil
}
68870
func (e *EncodeSession) Stop() error {
	e.Lock()
	defer e.Unlock()
	if !e.running || e.process == nil {
		return errors.New("Not running")
	}

	err := e.process.Kill()
	return err
}
426443
func (l *Lifecycle) Stop(ctx context.Context) error {
	var errs []error
	// Run backward from last successful OnStart.
	for ; l.numStarted > 0; l.numStarted-- {
		hook := l.hooks[l.numStarted-1]
		if hook.OnStop == nil {
			continue
		}
		l.logger.Printf("STOP\t\t%s()", hook.caller)
		if err := hook.OnStop(ctx); err != nil {
			// For best-effort cleanup, keep going after errors.
			errs = append(errs, err)
		}
	}
	return multierr.Combine(errs...)
}
365828
func (s *Scheduler) Stop(ctx context.Context, containerID string) error {
	container, err := s.docker.InspectContainer(containerID)
	if err != nil {
		return err
	}

	// Some extra protection around stopping containers. We don't want to
	// allow users to stop containers that may have been started outside of
	// Empire.
	if _, ok := container.Config.Labels[runLabel]; !ok {
		return &docker.NoSuchContainer{
			ID: containerID,
		}
	}

	if err := s.docker.StopContainer(ctx, containerID, stopContainerTimeout); err != nil {
		return err
	}

	return nil
}
532270
func (l *ServiceListener) Stop(reqs []StateRequest) (int, bool) {
	delta := 0
	ok := true

	for _, req := range reqs {

		logger := plog.WithFields(log.Fields{
			"hostid":     req.HostID,
			"serviceid":  req.ServiceID,
			"instanceid": req.InstanceID,
		})

		isOnline, err := IsHostOnline(l.conn, req.PoolID, req.HostID)

		if err != nil {

			logger.WithError(err).Warn("Could not verify whether host is online")
			ok = false
			continue
		}

		if isOnline {
			if err := UpdateState(l.conn, req, func(s *State) bool {
				if s.DesiredState != service.SVCStop {
					s.DesiredState = service.SVCStop
					return true
				}
				return false
			}); err != nil {

				logger.WithError(err).Warn("Could not stop service state")
				ok = false
				continue
			}

			logger.Debug("Set desired state to stop since host is online")

		} else {
			if err := DeleteState(l.conn, req); err != nil {

				logger.WithError(err).Warn("Could not remove service state")
				ok = false
				continue
			}

			logger.Debug("Removed state since host is offline")
		}
		delta++
	}

	return delta, ok
}
1212737
func (s Service) Stop() error {
	running, err := s.Running()
	if err != nil {
		return errors.Trace(err)
	}
	if !running {
		return nil
	}

	args := []string{"stop", s.Name()}
	return s.execThenExpect(args, "Stopped.")
}
472789
func PauseCommand(factory app.ProjectFactory) cli.Command {
	return cli.Command{
		Name:  "pause",
		Usage: "Pause services.",
		// ArgsUsage: "[SERVICE...]",
		Action: app.WithProject(factory, app.ProjectPause),
	}
}
1256748
func (r *runtimeOCI) PauseContainer(c *Container) error {
	c.opLock.Lock()
	defer c.opLock.Unlock()

	_, err := utils.ExecCmd(r.path, rootFlag, r.root, "pause", c.id)
	return err
}
462655
func (t *Timer) Stop() bool {
	if t.timer != nil {
		return t.timer.Stop()
	}

	registered := !t.stopped
	t.mock.removeClockTimer((*internalTimer)(t))
	t.stopped = true
	return registered
}