package proxy import ( "context" "fmt" "time" "gitea.timerzz.com/kedaya_haitao/proxy-detector/log" healthcheck "gitea.timerzz.com/kedaya_haitao/proxy-detector/pkg/health-check" "gitea.timerzz.com/kedaya_haitao/proxy-detector/pkg/proxy/structs" ) func CronHealthCheck(ctx context.Context, interval int) { ticker := time.NewTicker(time.Duration(interval) * time.Minute) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: log.Infoln("Starting health check...") proxies := healthcheck.CleanBadProxies(ctx, structs.ProxiesList.Get()) structs.ProxiesList.Replace(proxies) log.Infoln("Health check completed.") log.Infoln(fmt.Sprintf("目前共%d个代理", len(proxies))) } } }