Skip to content

Commit

Permalink
chore: fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie0129 committed Feb 17, 2025
1 parent 3dc4cab commit cd02fbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gochecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ jobs:
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.GOLANGCI_VERSION }}
verify: false
20 changes: 13 additions & 7 deletions loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,20 @@ func maintainLoop() bool {
logrus.Debugf("this maintain loop waited %d seconds after being initiated, now ready to execute", int(tsAfterWait.Sub(tsBeforeWait).Seconds()))
}

lastRecord := loopRecorder.GetLastRecord()
diff := time.Since(lastRecord)
if diff > loopInterval+time.Second {
// TODO: put it in a function (and the similar code in maintainLoopForced)
maintainLoopCount := loopRecorder.GetRecordsIn(time.Minute * 2)
expectedMaintainLoopCount := int(time.Minute * 2 / loopInterval)
minMaintainLoopCount := expectedMaintainLoopCount - 1
relativeTimes := loopRecorder.GetRecordsRelativeToCurrent(time.Minute * 2)
// If maintain loop is missed too many times, we assume the system is in a rapid sleep/wake loop, or macOS
// haven't sent the sleep notification but the system is actually sleep/waking up. In either case, log it.
if maintainLoopCount < minMaintainLoopCount {
logrus.WithFields(logrus.Fields{
"lastRecord": loopRecorder.GetLastRecord(),
"interval": loopInterval.String(),
"actual": diff.String(),
}).Warn("possible missed maintain loop")
"maintainLoopCount": maintainLoopCount,
"expectedMaintainLoopCount": expectedMaintainLoopCount,
"minMaintainLoopCount": minMaintainLoopCount,
"relativeTimes": relativeTimes,
}).Infof("Possibly missed maintain loop")
}

loopRecorder.AddRecord()
Expand Down

0 comments on commit cd02fbd

Please sign in to comment.