Skip to content
Snippets Groups Projects
Commit 7520ac85 authored by Juergen Enge's avatar Juergen Enge
Browse files

policy watcher looks reacts on create

parent f397a6a2
No related merge requests found
Pipeline #163911 passed
......@@ -6,6 +6,7 @@ import (
"github.com/fsnotify/fsnotify"
"github.com/je4/utils/v2/pkg/zLogger"
"sync"
"time"
)
func NewManager(configFile string, logger zLogger.ZLogger) *Manager {
......@@ -46,7 +47,12 @@ func (m *Manager) Start(wg *sync.WaitGroup) error {
m.logger.Info().Msg("stop watching policies")
return
case event := <-watcher.Events:
if event.Has(fsnotify.Write) {
if event.Has(fsnotify.Create) {
time.Sleep(100 * time.Millisecond)
if err := m.load(); err != nil {
m.logger.Error().Err(err).Msg("cannot load policies")
}
} else if event.Has(fsnotify.Write) {
if err := m.load(); err != nil {
m.logger.Error().Err(err).Msg("cannot load policies")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment