mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-29 09:16:35 +08:00
执行定时任务时自动根据负载进行延后执行
This commit is contained in:
@@ -140,3 +140,13 @@ func calculateDiskMaxWrites() {
|
||||
DiskMaxWrites = 4
|
||||
}
|
||||
}
|
||||
|
||||
// WaitLoad wait system load to downgrade
|
||||
func WaitLoad(maxLoad float64, maxLoops int, delay time.Duration) {
|
||||
for i := 0; i < maxLoops; i++ {
|
||||
stat, err := load.Avg()
|
||||
if err == nil && stat.Load1 > maxLoad {
|
||||
time.Sleep(delay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user