defer closing tailable file via subcontext

+ update deps for defer f.Close()
This commit is contained in:
2022-11-06 14:41:09 +02:00
parent 4554ddb188
commit 1617658d1a
3 changed files with 7 additions and 3 deletions

View File

@@ -117,8 +117,10 @@ func (s *submitter) shipFileRoutine(ctx context.Context, name string, deleteOk f
}
startSize := fi.Size()
// TODO: use inotify for file, and end with file deletion or replacement
lineChan, errChan, err := util.TailFile(ctx, name, log.Offset, io.SeekStart)
sctx, cancel := context.WithCancel(ctx)
defer cancel()
lineChan, errChan, err := util.TailFile(sctx, name, log.Offset, io.SeekStart)
if err != nil {
return fmt.Errorf("tailing file: %w", err)
}