mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
lint: Move out config reloader context from controller struct
Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
committed by
Ramkumar Chinchani
parent
353b0c6034
commit
be910cf01c
@@ -1,6 +1,8 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/rs/zerolog/log"
|
||||
"zotregistry.io/zot/pkg/api"
|
||||
@@ -29,8 +31,10 @@ func NewHotReloader(ctlr *api.Controller, filePath string) (*HotReloader, error)
|
||||
return hotReloader, nil
|
||||
}
|
||||
|
||||
func (hr *HotReloader) Start() {
|
||||
func (hr *HotReloader) Start() context.Context {
|
||||
done := make(chan bool)
|
||||
|
||||
reloadCtx, cancelOnReloadFunc := context.WithCancel(context.Background())
|
||||
// run watcher
|
||||
go func() {
|
||||
defer hr.watcher.Close()
|
||||
@@ -51,8 +55,12 @@ func (hr *HotReloader) Start() {
|
||||
|
||||
continue
|
||||
}
|
||||
// if valid config then reload
|
||||
cancelOnReloadFunc()
|
||||
|
||||
hr.ctlr.LoadNewConfig(newConfig)
|
||||
// create new context
|
||||
reloadCtx, cancelOnReloadFunc = context.WithCancel(context.Background())
|
||||
hr.ctlr.LoadNewConfig(reloadCtx, newConfig)
|
||||
}
|
||||
// watch for errors
|
||||
case err := <-hr.watcher.Errors:
|
||||
@@ -69,4 +77,6 @@ func (hr *HotReloader) Start() {
|
||||
|
||||
<-done
|
||||
}()
|
||||
|
||||
return reloadCtx
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user