mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vmalert: properly init SIGHUP listener before starting group manager (#1725)
Regression was introduced during code refactoring. It potentially could lead to situation when SIGHUP signals were ignored while vmalert was still busy with initing group manager. Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
0a1982b294
commit
627224d493
2 changed files with 9 additions and 8 deletions
|
@ -127,11 +127,16 @@ func main() {
|
|||
logger.Fatalf("cannot parse configuration file: %s", err)
|
||||
}
|
||||
|
||||
// Register SIGHUP handler for config re-read just before manager.start call.
|
||||
// This guarantees that the config will be re-read if the signal arrives during manager.start call.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1240
|
||||
sighupCh := procutil.NewSighupChan()
|
||||
|
||||
if err := manager.start(ctx, groupsCfg); err != nil {
|
||||
logger.Fatalf("failed to start: %s", err)
|
||||
}
|
||||
|
||||
go configReload(ctx, manager, groupsCfg)
|
||||
go configReload(ctx, manager, groupsCfg, sighupCh)
|
||||
|
||||
rh := &requestHandler{m: manager}
|
||||
go httpserver.Serve(*httpListenAddr, rh.handler)
|
||||
|
@ -245,12 +250,7 @@ See the docs at https://docs.victoriametrics.com/vmalert.html .
|
|||
flagutil.Usage(s)
|
||||
}
|
||||
|
||||
func configReload(ctx context.Context, m *manager, groupsCfg []config.Group) {
|
||||
// Register SIGHUP handler for config re-read just before manager.start call.
|
||||
// This guarantees that the config will be re-read if the signal arrives during manager.start call.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1240
|
||||
sighupCh := procutil.NewSighupChan()
|
||||
|
||||
func configReload(ctx context.Context, m *manager, groupsCfg []config.Group, sighupCh <-chan os.Signal) {
|
||||
var configCheckCh <-chan time.Time
|
||||
if *rulesCheckInterval > 0 {
|
||||
ticker := time.NewTicker(*rulesCheckInterval)
|
||||
|
|
|
@ -102,8 +102,9 @@ groups:
|
|||
}
|
||||
|
||||
syncCh := make(chan struct{})
|
||||
sighupCh := procutil.NewSighupChan()
|
||||
go func() {
|
||||
configReload(ctx, m, nil)
|
||||
configReload(ctx, m, nil, sighupCh)
|
||||
close(syncCh)
|
||||
}()
|
||||
|
||||
|
|
Loading…
Reference in a new issue