mirror of
https://github.com/go-kratos/kratos.git
synced 2025-07-17 01:42:34 +02:00
avoid ticker leak when cpustat.ReadStat(...) panic
This commit is contained in:
@ -32,13 +32,15 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cpuproc() {
|
func cpuproc() {
|
||||||
|
ticker := time.NewTicker(time.Millisecond * 250)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
ticker.Stop()
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
log.Error("rate.limit.cpuproc() err(%+v)", err)
|
log.Error("rate.limit.cpuproc() err(%+v)", err)
|
||||||
go cpuproc()
|
go cpuproc()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ticker := time.NewTicker(time.Millisecond * 250)
|
|
||||||
// EMA algorithm: https://blog.csdn.net/m0_38106113/article/details/81542863
|
// EMA algorithm: https://blog.csdn.net/m0_38106113/article/details/81542863
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
stat := &cpustat.Stat{}
|
stat := &cpustat.Stat{}
|
||||||
|
Reference in New Issue
Block a user