summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-16 20:33:38 +0300
committerValery Piashchynski <[email protected]>2020-12-16 20:33:38 +0300
commit6b767417b0d76b258648f9e7fd5984bb83a32d4e (patch)
tree0cccc31823235d53840381fc70048e34dba55833
parent29fdca1ec6ae2c95e5aec3d76d62cd2bc3b828e8 (diff)
Add logs config
Reduce number of goroutines since they was locked by mutexes
-rw-r--r--plugins/logger/tests/.rr.yaml3
-rw-r--r--plugins/logger/tests/logger_test.go2
-rw-r--r--plugins/reload/tests/configs/.rr-reload-2.yaml3
-rw-r--r--plugins/reload/tests/configs/.rr-reload-3.yaml3
-rw-r--r--plugins/reload/tests/configs/.rr-reload-4.yaml3
-rw-r--r--plugins/reload/tests/configs/.rr-reload.yaml3
-rw-r--r--plugins/reload/watcher.go9
7 files changed, 19 insertions, 7 deletions
diff --git a/plugins/logger/tests/.rr.yaml b/plugins/logger/tests/.rr.yaml
index e69de29b..cb555ec3 100644
--- a/plugins/logger/tests/.rr.yaml
+++ b/plugins/logger/tests/.rr.yaml
@@ -0,0 +1,3 @@
+logs:
+ mode: development
+ level: debug \ No newline at end of file
diff --git a/plugins/logger/tests/logger_test.go b/plugins/logger/tests/logger_test.go
index 1df74c47..3e6faf1f 100644
--- a/plugins/logger/tests/logger_test.go
+++ b/plugins/logger/tests/logger_test.go
@@ -13,7 +13,7 @@ import (
)
func TestLogger(t *testing.T) {
- container, err := endure.NewContainer(nil, endure.RetryOnFail(true), endure.SetLogLevel(endure.DebugLevel))
+ container, err := endure.NewContainer(nil, endure.RetryOnFail(true), endure.SetLogLevel(endure.ErrorLevel))
if err != nil {
t.Fatal(err)
}
diff --git a/plugins/reload/tests/configs/.rr-reload-2.yaml b/plugins/reload/tests/configs/.rr-reload-2.yaml
index 6c00eeb9..5be3179b 100644
--- a/plugins/reload/tests/configs/.rr-reload-2.yaml
+++ b/plugins/reload/tests/configs/.rr-reload-2.yaml
@@ -30,6 +30,9 @@ http:
maxJobs: 0
allocateTimeout: 60s
destroyTimeout: 60s
+logs:
+ mode: development
+ level: error
reload:
interval: 2s
patterns:
diff --git a/plugins/reload/tests/configs/.rr-reload-3.yaml b/plugins/reload/tests/configs/.rr-reload-3.yaml
index ad883f2d..b97ed667 100644
--- a/plugins/reload/tests/configs/.rr-reload-3.yaml
+++ b/plugins/reload/tests/configs/.rr-reload-3.yaml
@@ -30,6 +30,9 @@ http:
maxJobs: 0
allocateTimeout: 60s
destroyTimeout: 60s
+logs:
+ mode: development
+ level: error
reload:
interval: 2s
patterns:
diff --git a/plugins/reload/tests/configs/.rr-reload-4.yaml b/plugins/reload/tests/configs/.rr-reload-4.yaml
index b74effe6..b664b836 100644
--- a/plugins/reload/tests/configs/.rr-reload-4.yaml
+++ b/plugins/reload/tests/configs/.rr-reload-4.yaml
@@ -30,6 +30,9 @@ http:
maxJobs: 0
allocateTimeout: 60s
destroyTimeout: 60s
+logs:
+ mode: development
+ level: error
reload:
interval: 2s
patterns:
diff --git a/plugins/reload/tests/configs/.rr-reload.yaml b/plugins/reload/tests/configs/.rr-reload.yaml
index 52511aa1..5e223db3 100644
--- a/plugins/reload/tests/configs/.rr-reload.yaml
+++ b/plugins/reload/tests/configs/.rr-reload.yaml
@@ -30,6 +30,9 @@ http:
maxJobs: 0
allocateTimeout: 60s
destroyTimeout: 60s
+logs:
+ mode: development
+ level: error
reload:
interval: 1s
patterns:
diff --git a/plugins/reload/watcher.go b/plugins/reload/watcher.go
index d1e1a4cd..2ba02be2 100644
--- a/plugins/reload/watcher.go
+++ b/plugins/reload/watcher.go
@@ -217,10 +217,9 @@ func (w *Watcher) waitEvent(d time.Duration) error {
// because we have to wait on Lock
// better is to listen files in parallel, but, since that would be used in debug... TODO
for serviceName := range w.watcherConfigs {
- go func(sn string, c WatcherConfig) {
- fileList, _ := w.retrieveFileList(sn, c)
- w.pollEvents(c.ServiceName, fileList)
- }(serviceName, w.watcherConfigs[serviceName])
+ // TODO sync approach
+ fileList, _ := w.retrieveFileList(serviceName, w.watcherConfigs[serviceName])
+ w.pollEvents(w.watcherConfigs[serviceName].ServiceName, fileList)
}
}
}
@@ -228,8 +227,6 @@ func (w *Watcher) waitEvent(d time.Duration) error {
// retrieveFileList get file list for service
func (w *Watcher) retrieveFileList(serviceName string, config WatcherConfig) (map[string]os.FileInfo, error) {
- w.mu.Lock()
- defer w.mu.Unlock()
fileList := make(map[string]os.FileInfo)
if config.Recursive {
// walk through directories recursively