Skip to content

Commit

Permalink
Merge pull request #2653 from aledbf/remove-watch
Browse files Browse the repository at this point in the history
Remove dummy file watcher
  • Loading branch information
k8s-ci-robot authored Jun 17, 2018
2 parents c4ec773 + f782929 commit 373f8f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 58 deletions.
54 changes: 26 additions & 28 deletions internal/ingress/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,44 +163,42 @@ Error loading new template: %v

n.t = ngxTpl

// TODO: refactor
if _, ok := fs.(filesystem.DefaultFs); !ok {
watch.NewDummyFileWatcher(tmplPath, onTemplateChange)
} else {
// do not setup watchers on tests
return n
}

_, err = watch.NewFileWatcher(tmplPath, onTemplateChange)
if err != nil {
glog.Fatalf("Error creating file watcher for %v: %v", tmplPath, err)
}

_, err = watch.NewFileWatcher(tmplPath, onTemplateChange)
filesToWatch := []string{}
err = filepath.Walk("/etc/nginx/geoip/", func(path string, info os.FileInfo, err error) error {
if err != nil {
glog.Fatalf("Error creating file watcher for %v: %v", tmplPath, err)
return err
}

filesToWatch := []string{}
err := filepath.Walk("/etc/nginx/geoip/", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}

if info.IsDir() {
return nil
}
filesToWatch = append(filesToWatch, path)
return nil
})

filesToWatch = append(filesToWatch, path)
return nil
})
if err != nil {
glog.Fatalf("Error creating file watchers: %v", err)
}

for _, f := range filesToWatch {
_, err = watch.NewFileWatcher(f, func() {
glog.Info("File %v changed. Reloading NGINX", f)
n.SetForceReload(true)
})
if err != nil {
glog.Fatalf("Error creating file watchers: %v", err)
glog.Fatalf("Error creating file watcher for %v: %v", f, err)
}

for _, f := range filesToWatch {
_, err = watch.NewFileWatcher(f, func() {
glog.Info("File %v changed. Reloading NGINX", f)
n.SetForceReload(true)
})
if err != nil {
glog.Fatalf("Error creating file watcher for %v: %v", f, err)
}
}

}

return n
Expand Down
30 changes: 0 additions & 30 deletions internal/watch/dummy.go

This file was deleted.

0 comments on commit 373f8f5

Please sign in to comment.