aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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()
}