(serviceContext context.Context)
| 44 | } |
| 45 | |
| 46 | func (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 | |
| 73 | func (w *moduleService) run(serviceContext context.Context) error { |
| 74 | // wait until service stops, or context is canceled, whatever happens first. |
nothing calls this directly
no test coverage detected