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 <rene@renesp.com.br>
  • Loading branch information
rene authored and eriknordmark committed Nov 26, 2023
1 parent bb2853e commit 27f47c1
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 @@ -320,7 +320,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 @@ -1012,7 +1012,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 @@ -1053,8 +1053,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 27f47c1

Please sign in to comment.