Skip to content

Commit e7fec1c

Browse files
authored
Merge pull request #1662 from grafana/20190910_refactor_webreload_chan
use global channel for all alertmanager web reloads
2 parents b80d1f6 + 24b4dd9 commit e7fec1c

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

pkg/alertmanager/alertmanager.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ type Alertmanager struct {
6767
registry *prometheus.Registry
6868
}
6969

70+
var webReload = make(chan chan error)
71+
72+
func init() {
73+
go func() {
74+
for {
75+
select {
76+
// Since this is not a "normal" Alertmanager which reads its config
77+
// from disk, we just ignore web-based reload signals. Config updates are
78+
// only applied externally via ApplyConfig().
79+
case <-webReload:
80+
}
81+
}
82+
}()
83+
}
84+
7085
// New creates a new Alertmanager.
7186
func New(cfg *Config) (*Alertmanager, error) {
7287
am := &Alertmanager{
@@ -142,23 +157,9 @@ func New(cfg *Config) (*Alertmanager, error) {
142157

143158
router := route.New().WithPrefix(am.cfg.ExternalURL.Path)
144159

145-
webReload := make(chan chan error)
146160
ui.Register(router, webReload, log.With(am.logger, "component", "ui"))
147161
am.mux = am.api.Register(router, am.cfg.ExternalURL.Path)
148162

149-
go func() {
150-
for {
151-
select {
152-
// Since this is not a "normal" Alertmanager which reads its config
153-
// from disk, we just ignore web-based reload signals. Config updates are
154-
// only applied externally via ApplyConfig().
155-
case <-webReload:
156-
case <-am.stop:
157-
return
158-
}
159-
}
160-
}()
161-
162163
return am, nil
163164
}
164165

0 commit comments

Comments
 (0)