mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
fix: down systems jamming the system update queue
This commit is contained in:
14
hub/main.go
14
hub/main.go
@@ -235,12 +235,18 @@ func updateSystems() {
|
|||||||
}
|
}
|
||||||
fiftySecondsAgo := time.Now().UTC().Add(-50 * time.Second)
|
fiftySecondsAgo := time.Now().UTC().Add(-50 * time.Second)
|
||||||
batchSize := len(records)/4 + 1
|
batchSize := len(records)/4 + 1
|
||||||
for i := 0; i < batchSize; i++ {
|
done := 0
|
||||||
if records[i].GetDateTime("updated").Time().After(fiftySecondsAgo) {
|
for _, record := range records {
|
||||||
|
// break if batch size reached or if the system was updated less than 50 seconds ago
|
||||||
|
if done >= batchSize || record.GetDateTime("updated").Time().After(fiftySecondsAgo) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// log.Println("updating", records[i].Get(("name")))
|
// don't increment for down systems to avoid them jamming the queue
|
||||||
go updateSystem(records[i])
|
// because they're always first when sorted by least recently updated
|
||||||
|
if record.GetString("status") != "down" {
|
||||||
|
done++
|
||||||
|
}
|
||||||
|
go updateSystem(record)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user