diff --git a/service/profile/config-update.go b/service/profile/config-update.go index acbe7b85..f3e8161c 100644 --- a/service/profile/config-update.go +++ b/service/profile/config-update.go @@ -23,7 +23,7 @@ var ( cfgFilterLists []string ) -func registerConfigUpdater() error { +func registerGlobalConfigProfileUpdater() error { module.instance.Config().EventConfigChange.AddCallback("update global config profile", func(wc *mgr.WorkerCtx, s struct{}) (cancel bool, err error) { return false, updateGlobalConfigProfile(wc.Ctx()) }) diff --git a/service/profile/module.go b/service/profile/module.go index 01659c76..911ef99c 100644 --- a/service/profile/module.go +++ b/service/profile/module.go @@ -61,10 +61,6 @@ func prep() error { return err } - if err := registerConfigUpdater(); err != nil { - return err - } - if err := registerMigrations(); err != nil { return err } @@ -118,6 +114,12 @@ func start() error { module.mgr.Go("clean active profiles", cleanActiveProfiles) + // Register config callback when starting, as it depends on the updates module, + // but the config system will already submit events earlier. + if err := registerGlobalConfigProfileUpdater(); err != nil { + return err + } + err = updateGlobalConfigProfile(module.mgr.Ctx()) if err != nil { log.Warningf("profile: error during loading global profile from configuration: %s", err)