()
| 84 | } |
| 85 | |
| 86 | func start() error { |
| 87 | if err := loadProfilesMetadata(); err != nil { |
| 88 | if !errors.Is(err, database.ErrNotFound) { |
| 89 | log.Warningf("profile: failed to load profiles metadata, falling back to empty state: %s", err) |
| 90 | } |
| 91 | meta = &ProfilesMetadata{} |
| 92 | } |
| 93 | meta.check() |
| 94 | |
| 95 | if err := migrations.Migrate(module.mgr.Ctx()); err != nil { |
| 96 | log.Errorf("profile: migrations failed: %s", err) |
| 97 | } |
| 98 | |
| 99 | err := registerValidationDBHook() |
| 100 | if err != nil { |
| 101 | return err |
| 102 | } |
| 103 | |
| 104 | err = registerRevisionProvider() |
| 105 | if err != nil { |
| 106 | return err |
| 107 | } |
| 108 | |
| 109 | err = startProfileUpdateChecker() |
| 110 | if err != nil { |
| 111 | return err |
| 112 | } |
| 113 | |
| 114 | module.mgr.Go("clean active profiles", cleanActiveProfiles) |
| 115 | |
| 116 | // Register config callback when starting, as it depends on the updates module, |
| 117 | // but the config system will already submit events earlier. |
| 118 | if err := registerGlobalConfigProfileUpdater(); err != nil { |
| 119 | return err |
| 120 | } |
| 121 | |
| 122 | err = updateGlobalConfigProfile(module.mgr.Ctx()) |
| 123 | if err != nil { |
| 124 | log.Warningf("profile: error during loading global profile from configuration: %s", err) |
| 125 | } |
| 126 | |
| 127 | return nil |
| 128 | } |
| 129 | |
| 130 | func stop() error { |
| 131 | return meta.Save() |
no test coverage detected