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

Method Up

pkg/compose/up.go:44–303  ·  pkg/compose/up.go::composeService.Up
(ctx context.Context, project *types.Project, options api.UpOptions)

Source from the content-addressed store, hash-verified

42)
43
44func (s *composeService) Up(ctx context.Context, project *types.Project, options api.UpOptions) error { //nolint:gocyclo
45 err := Run(ctx, tracing.SpanWrapFunc("project/up", tracing.ProjectOptions(ctx, project), func(ctx context.Context) error {
46 err := s.create(ctx, project, options.Create)
47 if err != nil {
48 return err
49 }
50 if options.Start.Attach == nil {
51 return s.start(ctx, project.Name, options.Start, nil)
52 }
53 return nil
54 }), "up", s.events)
55 if err != nil {
56 return err
57 }
58
59 if options.Start.Attach == nil {
60 return err
61 }
62 if s.dryRun {
63 _, _ = fmt.Fprintln(s.stdout(), "end of 'compose up' output, interactive run is not supported in dry-run mode")
64 return err
65 }
66
67 // if we get a second signal during shutdown, we kill the services
68 // immediately, so the channel needs to have sufficient capacity or
69 // we might miss a signal while setting up the second channel read
70 // (this is also why signal.Notify is used vs signal.NotifyContext)
71 signalChan := make(chan os.Signal, 2)
72 signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
73 defer signal.Stop(signalChan)
74 var isTerminated atomic.Bool
75
76 var (
77 logConsumer = options.Start.Attach
78 navigationMenu *formatter.LogKeyboard
79 kEvents <-chan keyboard.KeyEvent
80 )
81 if options.Start.NavigationMenu {
82 kEvents, err = keyboard.GetKeys(100)
83 if err != nil {
84 logrus.Warnf("could not start menu, an error occurred while starting: %v", err)
85 options.Start.NavigationMenu = false
86 } else {
87 defer keyboard.Close() //nolint:errcheck
88 isDockerDesktopActive, err := s.isDesktopIntegrationActive(ctx)
89 if err != nil {
90 return err
91 }
92 isLogsViewEnabled := s.isDesktopFeatureActive(ctx, desktop.FeatureLogsTab)
93 tracing.KeyboardMetrics(ctx, options.Start.NavigationMenu, isDockerDesktopActive, isLogsViewEnabled)
94 navigationMenu = formatter.NewKeyboardManager(isDockerDesktopActive, isLogsViewEnabled, signalChan)
95 logConsumer = navigationMenu.Decorate(logConsumer)
96 }
97 }
98
99 watcher, err := NewWatcher(project, options, s.watch, logConsumer)
100 if err != nil && options.Start.Watch {
101 return err

Callers

nothing calls this directly

Calls 15

createMethod · 0.95
startMethod · 0.95
stdoutMethod · 0.95
stopMethod · 0.95
StopMethod · 0.95
killMethod · 0.95
StartMethod · 0.95
apiClientMethod · 0.95
attachMethod · 0.95
doLogContainerMethod · 0.95

Tested by

no test coverage detected