(ctx context.Context, service *types.ServiceConfig, ctr containerType.Summary, timeout *time.Duration, listener api.ContainerEventListener)
| 296 | } |
| 297 | |
| 298 | func (s *composeService) stopContainer(ctx context.Context, service *types.ServiceConfig, ctr containerType.Summary, timeout *time.Duration, listener api.ContainerEventListener) error { |
| 299 | eventName := getContainerProgressName(ctr) |
| 300 | s.events.On(newEvent(eventName, api.Working, api.StatusStopping)) |
| 301 | |
| 302 | if service != nil { |
| 303 | for _, hook := range service.PreStop { |
| 304 | err := s.runHook(ctx, ctr, *service, hook, listener) |
| 305 | if err != nil { |
| 306 | // Ignore errors indicating that some containers were already stopped or removed. |
| 307 | if errdefs.IsNotFound(err) || errdefs.IsConflict(err) { |
| 308 | return nil |
| 309 | } |
| 310 | return err |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | _, err := s.apiClient().ContainerStop(ctx, ctr.ID, client.ContainerStopOptions{ |
| 316 | Timeout: utils.DurationSecondToInt(timeout), |
| 317 | }) |
| 318 | if err != nil { |
| 319 | s.events.On(errorEvent(eventName, "Error while Stopping")) |
| 320 | return err |
| 321 | } |
| 322 | s.events.On(newEvent(eventName, api.Done, api.StatusStopped)) |
| 323 | return nil |
| 324 | } |
| 325 | |
| 326 | func (s *composeService) stopContainers(ctx context.Context, serv *types.ServiceConfig, containers []containerType.Summary, timeout *time.Duration, listener api.ContainerEventListener) error { |
| 327 | eg, ctx := errgroup.WithContext(ctx) |
no test coverage detected