mirror of
https://github.com/Icinga/icingadb.git
synced 2026-06-08 16:34:29 -04:00
Start history retention after config and state sync
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
This commit is contained in:
parent
73f4639d35
commit
2c09dd9e1c
1 changed files with 22 additions and 0 deletions
|
|
@ -131,6 +131,14 @@ func run() int {
|
|||
hs := history.NewSync(db, rc, logs.GetChildLogger("history-sync"))
|
||||
rt := icingadb.NewRuntimeUpdates(db, rc, logs.GetChildLogger("runtime-updates"))
|
||||
ods := overdue.NewSync(db, rc, logs.GetChildLogger("overdue-sync"))
|
||||
ret := history.NewRetention(
|
||||
db,
|
||||
cmd.Config.HistoryRetention.Days,
|
||||
cmd.Config.HistoryRetention.Interval,
|
||||
cmd.Config.HistoryRetention.Count,
|
||||
cmd.Config.HistoryRetention.Options,
|
||||
logs.GetChildLogger("history-retention"),
|
||||
)
|
||||
|
||||
sig := make(chan os.Signal, 1)
|
||||
signal.Notify(sig, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
|
||||
|
|
@ -281,6 +289,20 @@ func run() int {
|
|||
return rt.Sync(synctx, v1.StateFactories, runtimeStateUpdateStreams, true)
|
||||
})
|
||||
|
||||
g.Go(func() error {
|
||||
// Wait for config and state sync to avoid putting additional pressure on the database.
|
||||
configInitSync.Wait()
|
||||
stateInitSync.Wait()
|
||||
|
||||
if err := synctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Info("Starting history retention")
|
||||
|
||||
return ret.Start(synctx)
|
||||
})
|
||||
|
||||
if err := g.Wait(); err != nil && !utils.IsContextCanceled(err) {
|
||||
logger.Fatalf("%+v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue