health check was firing way too often, fix some logic to keep it around 1min, not every 5 seconds
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dan Ballard 2022-04-09 08:31:16 -07:00
parent a27fd47755
commit d13dc5529b
1 changed files with 5 additions and 2 deletions

View File

@ -16,6 +16,8 @@ const NetworkCheckError = "Error"
// NetworkCheckSuccess is a status for when the NetworkCheck Plugin has had a successful message from a peer, indicating it is online right now
const NetworkCheckSuccess = "Success"
const NetworkCheckPeriod = time.Minute
// networkCheck is a convenience plugin for testing high level availability of onion services
type networkCheck struct {
bus event.Manager
@ -49,7 +51,7 @@ func (nc *networkCheck) run() {
nc.bus.Subscribe(event.ServerStateChange, nc.queue)
nc.bus.Subscribe(event.NewGetValMessageFromPeer, nc.queue)
nc.bus.Subscribe(event.NewRetValMessageFromPeer, nc.queue)
var lastMessageReceived time.Time
var lastMessageReceived = time.Now()
for {
select {
case <-nc.breakChan:
@ -97,10 +99,11 @@ func (nc *networkCheck) run() {
}
nc.offlineLock.Unlock()
}
case <-time.After(tickTime):
case <-time.After(NetworkCheckPeriod):
// if we haven't received an action in the last minute...kick off a set of testing
if time.Since(lastMessageReceived) > time.Minute {
nc.selfTest()
lastMessageReceived = time.Now()
}
}
}