Skip to content

Commit

Permalink
pkg/reloader: use watchInterval timeout for initial apply
Browse files Browse the repository at this point in the history
  • Loading branch information
captncraig committed Jul 10, 2023
1 parent b46b835 commit eb579ba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/reloader/reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,14 @@ func (r *Reloader) Watch(ctx context.Context) error {
}

defer runutil.CloseWithLogOnErr(r.logger, r.watcher, "config watcher close")
applyCtx, applyCancel := context.WithTimeout(ctx, r.watchInterval)

if r.cfgFile != "" {
if err := r.watcher.addFile(r.cfgFile); err != nil {
return errors.Wrapf(err, "add config file %s to watcher", r.cfgFile)
}

if err := r.apply(ctx); err != nil {
if err := r.apply(applyCtx); err != nil {
return err
}
}
Expand Down Expand Up @@ -238,7 +239,9 @@ func (r *Reloader) Watch(ctx context.Context) error {
"out", r.cfgOutputFile,
"dirs", strings.Join(r.watchedDirs, ","))

applyCtx, applyCancel := context.WithTimeout(ctx, r.watchInterval)
// Reset the watch timeout.
applyCancel()
applyCtx, applyCancel = context.WithTimeout(ctx, r.watchInterval)

for {
select {
Expand Down

0 comments on commit eb579ba

Please sign in to comment.