diff options
author | HimbeerserverDE <52707839+HimbeerserverDE@users.noreply.github.com> | 2022-04-21 14:43:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-21 14:43:19 +0200 |
commit | 61b3f3f659ccd1cbd6aeccb9b65b7a0ab01415a1 (patch) | |
tree | ecbb79d5d9df97e63622aa7e4508f1ff73ccd61a | |
parent | e15dce80549e3b8c0a8e5febbc08d833654fb69c (diff) | |
parent | e14f0b203a06271f563214febba9243838a7e71d (diff) |
Merge pull request #86 from ev2-1/Issue#68
Issue#68
-rw-r--r-- | config.go | 8 | ||||
-rw-r--r-- | run.go | 4 |
2 files changed, 8 insertions, 4 deletions
@@ -20,6 +20,8 @@ const ( var config Config var configMu sync.RWMutex +var loadConfigOnce sync.Once + // A Config contains information from the configuration file // that affects the way the proxy works. type Config struct { @@ -71,6 +73,12 @@ type Config struct { // Conf returns a copy of the Config used by the proxy. // Any modifications will not affect the original Config. func Conf() Config { + loadConfigOnce.Do(func (){ + if err := LoadConfig(); err != nil { + log.Fatal(err) + } + }) + configMu.RLock() defer configMu.RUnlock() @@ -19,10 +19,6 @@ func Run() { } func runFunc() { - if err := LoadConfig(); err != nil { - log.Fatal(err) - } - if !Conf().NoPlugins { loadPlugins() } |