MCPcopy Create free account
hub / github.com/cortexproject/cortex / start

Method start

pkg/util/modules/module_service.go:46–71  ·  view source on GitHub ↗
(serviceContext context.Context)

Source from the content-addressed store, hash-verified

44}
45
46func (w *moduleService) start(serviceContext context.Context) error {
47 // wait until all startDeps are running
48 startDeps := w.startDeps(w.name)
49 for m, s := range startDeps {
50 if s == nil {
51 continue
52 }
53
54 level.Debug(w.logger).Log("msg", "module waiting for initialization", "module", w.name, "waiting_for", m)
55
56 err := s.AwaitRunning(serviceContext)
57 if err != nil {
58 return fmt.Errorf("failed to start %v, because it depends on module %v, which has failed: %w", w.name, m, err)
59 }
60 }
61
62 // we don't want to let this service to stop until all dependent services are stopped,
63 // so we use independent context here
64 level.Info(w.logger).Log("msg", "initialising", "module", w.name)
65 err := w.service.StartAsync(context.Background())
66 if err != nil {
67 return errors.Wrapf(err, "error starting module: %s", w.name)
68 }
69
70 return w.service.AwaitRunning(serviceContext)
71}
72
73func (w *moduleService) run(serviceContext context.Context) error {
74 // wait until service stops, or context is canceled, whatever happens first.

Callers

nothing calls this directly

Calls 3

AwaitRunningMethod · 0.65
StartAsyncMethod · 0.65
LogMethod · 0.45

Tested by

no test coverage detected