nightingale1/timer/orphan_res.go

29 lines
583 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package timer
import (
"fmt"
"math/rand"
"time"
"github.com/didi/nightingale/v5/models"
)
// 是个兜底扫描器担心有些resource脱离id为1的preset的classpath
// 如果有发现就把resource重新bind回来
func BindOrphanRes() {
go loopBindOrphanRes()
}
func loopBindOrphanRes() {
randtime := rand.Intn(10000)
fmt.Printf("timer: bind orphan res: random sleep %dms\n", randtime)
time.Sleep(time.Duration(randtime) * time.Millisecond)
interval := time.Duration(10) * time.Second
for {
time.Sleep(interval)
models.BindOrphanToPresetClasspath()
}
}