Skip to content

Commit

Permalink
newlogd: Kick watchdog inside doMoveCompressFile()
Browse files Browse the repository at this point in the history
Kick watchdog inside doMoveCompressFile() because it can take longer to
execute depending on the file size, besides be affected by external
factors, like the system load, while parsing and compressing the contents.

Signed-off-by: Renê de Souza Pinto <[email protected]>
  • Loading branch information
rene authored and eriknordmark committed Nov 25, 2023
1 parent 86f6301 commit e9d2eeb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/newlog/cmd/newlogd.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func main() {

case tmpLogfileInfo := <-movefileChan:
// handle logfile to gzip conversion work
doMoveCompressFile(tmpLogfileInfo)
doMoveCompressFile(&ps, tmpLogfileInfo)

case panicBuf := <-panicFileChan:
// save panic stack into files
Expand Down Expand Up @@ -1032,7 +1032,7 @@ func checkKeepQuota() {
}
}

func doMoveCompressFile(tmplogfileInfo fileChanInfo) {
func doMoveCompressFile(ps *pubsub.PubSub, tmplogfileInfo fileChanInfo) {
isApp := tmplogfileInfo.isApp
dirName, appuuid := getFileInfo(tmplogfileInfo)

Expand Down Expand Up @@ -1073,8 +1073,13 @@ func doMoveCompressFile(tmplogfileInfo fileChanInfo) {
gw, underlayWriter, oTmpFile := prepareGzipToOutTempFile(filepath.Dir(outfile), tmplogfileInfo, now)

fileID := 0
wdTime := time.Now()
var newSize int64
for scanner.Scan() {
if time.Since(wdTime) >= (15 * time.Second) {
ps.StillRunning(agentName, warningTime, errorTime)
wdTime = time.Now()
}
newLine := scanner.Bytes()
//trim non-graphic symbols
newLine = bytes.TrimFunc(newLine, func(r rune) bool {
Expand Down

0 comments on commit e9d2eeb

Please sign in to comment.