lib: Apply config changes sequentially (ref #5298) (#7188)

This commit is contained in:
Simon Frei
2021-01-15 15:43:34 +01:00
committed by GitHub
parent b2d82da20d
commit f63cdbfcfa
20 changed files with 1032 additions and 790 deletions
+17 -16
View File
@@ -121,6 +121,10 @@ func (a *App) Start() error {
}
func (a *App) startup() error {
if cfgService, ok := a.cfg.(suture.Service); ok {
a.mainService.Add(cfgService)
}
a.mainService.Add(ur.NewFailureHandler(a.cfg, a.evLogger))
a.mainService.Add(a.ll)
@@ -277,24 +281,21 @@ func (a *App) startup() error {
a.mainService.Add(discoveryManager)
a.mainService.Add(connectionsService)
// Candidate builds always run with usage reporting.
if opts := a.cfg.Options(); build.IsCandidate {
l.Infoln("Anonymous usage reporting is always enabled for candidate releases.")
if opts.URAccepted != ur.Version {
opts.URAccepted = ur.Version
a.cfg.SetOptions(opts)
a.cfg.Save()
// Unique ID will be set and config saved below if necessary.
a.cfg.Modify(func(cfg *config.Configuration) {
// Candidate builds always run with usage reporting.
if build.IsCandidate {
l.Infoln("Anonymous usage reporting is always enabled for candidate releases.")
if cfg.Options.URAccepted != ur.Version {
cfg.Options.URAccepted = ur.Version
// Unique ID will be set and config saved below if necessary.
}
}
}
// If we are going to do usage reporting, ensure we have a valid unique ID.
if opts := a.cfg.Options(); opts.URAccepted > 0 && opts.URUniqueID == "" {
opts.URUniqueID = rand.String(8)
a.cfg.SetOptions(opts)
a.cfg.Save()
}
// If we are going to do usage reporting, ensure we have a valid unique ID.
if cfg.Options.URAccepted > 0 && cfg.Options.URUniqueID == "" {
cfg.Options.URUniqueID = rand.String(8)
}
})
usageReportingSvc := ur.New(a.cfg, m, connectionsService, a.opts.NoUpgrade)
a.mainService.Add(usageReportingSvc)