aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <52707839+HimbeerserverDE@users.noreply.github.com>2022-04-21 14:43:19 +0200
committerGitHub <noreply@github.com>2022-04-21 14:43:19 +0200
commit61b3f3f659ccd1cbd6aeccb9b65b7a0ab01415a1 (patch)
treeecbb79d5d9df97e63622aa7e4508f1ff73ccd61a
parente15dce80549e3b8c0a8e5febbc08d833654fb69c (diff)
parente14f0b203a06271f563214febba9243838a7e71d (diff)
Merge pull request #86 from ev2-1/Issue#68
Issue#68
-rw-r--r--config.go8
-rw-r--r--run.go4
2 files changed, 8 insertions, 4 deletions
diff --git a/config.go b/config.go
index 4adb4ae..84c1cc3 100644
--- a/config.go
+++ b/config.go
@@ -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()
diff --git a/run.go b/run.go
index f7ca66f..f7c1d72 100644
--- a/run.go
+++ b/run.go
@@ -19,10 +19,6 @@ func Run() {
}
func runFunc() {
- if err := LoadConfig(); err != nil {
- log.Fatal(err)
- }
-
if !Conf().NoPlugins {
loadPlugins()
}