| 473 | } |
| 474 | |
| 475 | func (am *Alertmanager) StopAndWait() { |
| 476 | am.Stop() |
| 477 | |
| 478 | if am.persister != nil { |
| 479 | if err := am.persister.AwaitTerminated(context.Background()); err != nil { |
| 480 | level.Warn(am.logger).Log("msg", "error while stopping state persister service", "err", err) |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | if service, ok := am.state.(services.Service); ok { |
| 485 | if err := service.AwaitTerminated(context.Background()); err != nil { |
| 486 | level.Warn(am.logger).Log("msg", "error while stopping ring-based replication service", "err", err) |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | am.wg.Wait() |
| 491 | } |
| 492 | |
| 493 | func (am *Alertmanager) mergePartialExternalState(part *clusterpb.Part) error { |
| 494 | if state, ok := am.state.(*state); ok { |