Skip to content

Commit

Permalink
Cancel upon watchInterval == 0
Browse files Browse the repository at this point in the history
Signed-off-by: Du Zheng <zsuzhengdu@gmail.com>
  • Loading branch information
zsuzhengdu committed Apr 1, 2021
1 parent fe63040 commit 29e2804
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pkg/reloader/reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ type Reloader struct {
retryInterval time.Duration
watchedDirs []string
watcher *watcher
oneOff bool

lastCfgHash []byte
lastWatchedDirsHash []byte
Expand All @@ -115,7 +114,6 @@ type Options struct {
CfgOutputFile string
// WatchedDirs is a collection of paths for the reloader to watch over.
WatchedDirs []string
OneOff bool
// DelayInterval controls how long the reloader will wait without receiving
// new file-system events before it applies the reload.
DelayInterval time.Duration
Expand All @@ -140,7 +138,6 @@ func New(logger log.Logger, reg prometheus.Registerer, o *Options) *Reloader {
cfgFile: o.CfgFile,
cfgOutputFile: o.CfgOutputFile,
watcher: newWatcher(logger, reg, o.DelayInterval),
oneOff: o.OneOff,
watchedDirs: o.WatchedDirs,
watchInterval: o.WatchInterval,
retryInterval: o.RetryInterval,
Expand Down Expand Up @@ -295,7 +292,7 @@ func (r *Reloader) apply(ctx context.Context) error {
return errors.Wrap(err, "rename file")
}

if r.oneOff {
if r.watchInterval == 0 {
<-ctx.Done()
return nil
}
Expand Down

0 comments on commit 29e2804

Please sign in to comment.