()
| 55 | } |
| 56 | |
| 57 | func Load() error { |
| 58 | if HasState() { |
| 59 | panic(errors.New("config already loaded")) |
| 60 | } |
| 61 | state := NewState() |
| 62 | config.WorkingState.Store(state) |
| 63 | |
| 64 | cfgWatcher = watcher.NewConfigFileWatcher(common.ConfigFileName) |
| 65 | |
| 66 | initErr := state.InitFromFile(common.ConfigPath) |
| 67 | if initErr != nil { |
| 68 | // if error is critical, notify and return it without starting providers |
| 69 | if criticalErr, ok := errors.AsType[CriticalError](initErr); ok { |
| 70 | logNotifyError("init", criticalErr.err) |
| 71 | return criticalErr |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // disable pool logging temporary since we already have pretty logging |
| 76 | state.Entrypoint().DisablePoolsLog(true) |
| 77 | defer func() { |
| 78 | state.Entrypoint().DisablePoolsLog(false) |
| 79 | }() |
| 80 | |
| 81 | err := errors.Join(initErr, state.StartProviders()) |
| 82 | if err != nil { |
| 83 | logNotifyError("init", err) |
| 84 | } |
| 85 | |
| 86 | state.StartAPIServers() |
| 87 | state.StartMetrics() |
| 88 | |
| 89 | SetState(state) |
| 90 | |
| 91 | // flush temporary log |
| 92 | state.FlushTmpLog() |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | func Reload() error { |
| 97 | events.Global.Add(events.NewEvent(events.LevelInfo, "config", "reload", nil)) |
no test coverage detected