MCPcopy
hub / github.com/docker/compose / kill

Method kill

pkg/compose/kill.go:35–72  ·  pkg/compose/kill.go::composeService.kill
(ctx context.Context, projectName string, options api.KillOptions)

Source from the content-addressed store, hash-verified

33}
34
35func (s *composeService) kill(ctx context.Context, projectName string, options api.KillOptions) error {
36 services := options.Services
37
38 var containers Containers
39 containers, err := s.getContainers(ctx, projectName, oneOffInclude, options.All, services...)
40 if err != nil {
41 return err
42 }
43
44 project := options.Project
45 if project == nil {
46 project, err = s.getProjectWithResources(ctx, containers, projectName)
47 if err != nil {
48 return err
49 }
50 }
51
52 if !options.RemoveOrphans {
53 containers = containers.filter(isService(project.ServiceNames()...))
54 }
55 if len(containers) == 0 {
56 return api.ErrNoResources
57 }
58
59 return forEachContainerConcurrent(ctx, containers, func(ctx context.Context, ctr container.Summary) error {
60 eventName := getContainerProgressName(ctr)
61 s.events.On(newEvent(eventName, api.Working, api.StatusKilling))
62 _, err := s.apiClient().ContainerKill(ctx, ctr.ID, client.ContainerKillOptions{
63 Signal: options.Signal,
64 })
65 if err != nil {
66 s.events.On(errorEvent(eventName, "Error while Killing"))
67 return err
68 }
69 s.events.On(newEvent(eventName, api.Done, api.StatusKilled))
70 return nil
71 })
72}

Callers 2

UpMethod · 0.95
KillMethod · 0.95

Calls 11

getContainersMethod · 0.95
filterMethod · 0.95
apiClientMethod · 0.95
isServiceFunction · 0.85
getContainerProgressNameFunction · 0.85
newEventFunction · 0.85
errorEventFunction · 0.85
OnMethod · 0.65
ContainerKillMethod · 0.45

Tested by

no test coverage detected