mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-05-15 14:38:19 +08:00
chore: health check for compatible providers after startup
This commit is contained in:
parent
5a2ed71bd9
commit
d80fcb77f6
@ -104,7 +104,7 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := provider.NewHealthCheck(ps, groupOption.URL, uint(groupOption.Interval), true, expectedStatus)
|
hc := provider.NewHealthCheck(ps, testUrl, uint(groupOption.Interval), groupOption.Lazy, expectedStatus)
|
||||||
|
|
||||||
pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
|
pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -252,6 +252,9 @@ func (cp *compatibleProvider) Update() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cp *compatibleProvider) Initial() error {
|
func (cp *compatibleProvider) Initial() error {
|
||||||
|
if cp.healthCheck.interval != 0 && cp.healthCheck.url != "" {
|
||||||
|
cp.HealthCheck()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ func ApplyConfig(cfg *config.Config, force bool) {
|
|||||||
loadRuleProvider(cfg.RuleProviders)
|
loadRuleProvider(cfg.RuleProviders)
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
tunnel.OnRunning()
|
tunnel.OnRunning()
|
||||||
|
hcCompatibleProvider(cfg.Providers)
|
||||||
|
|
||||||
log.SetLevel(cfg.General.LogLevel)
|
log.SetLevel(cfg.General.LogLevel)
|
||||||
}
|
}
|
||||||
@ -265,7 +266,7 @@ func updateRules(rules []C.Rule, subRules map[string][]C.Rule, ruleProviders map
|
|||||||
|
|
||||||
func loadProvider(pv provider.Provider) {
|
func loadProvider(pv provider.Provider) {
|
||||||
if pv.VehicleType() == provider.Compatible {
|
if pv.VehicleType() == provider.Compatible {
|
||||||
log.Infoln("Start initial compatible provider %s", pv.Name())
|
return
|
||||||
} else {
|
} else {
|
||||||
log.Infoln("Start initial provider %s", (pv).Name())
|
log.Infoln("Start initial provider %s", (pv).Name())
|
||||||
}
|
}
|
||||||
@ -318,7 +319,27 @@ func loadProxyProvider(proxyProviders map[string]provider.ProxyProvider) {
|
|||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) {
|
||||||
|
// limit concurrent size
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
ch := make(chan struct{}, concurrentCount)
|
||||||
|
for _, proxyProvider := range proxyProviders {
|
||||||
|
proxyProvider := proxyProvider
|
||||||
|
if proxyProvider.VehicleType() == provider.Compatible {
|
||||||
|
log.Infoln("Start initial Compatible provider %s", proxyProvider.Name())
|
||||||
|
wg.Add(1)
|
||||||
|
ch <- struct{}{}
|
||||||
|
go func() {
|
||||||
|
defer func() { <-ch; wg.Done() }()
|
||||||
|
if err := proxyProvider.Initial(); err != nil {
|
||||||
|
log.Errorln("initial Compatible provider %s error: %v", proxyProvider.Name(), err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
func updateTun(general *config.General) {
|
func updateTun(general *config.General) {
|
||||||
if general == nil {
|
if general == nil {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user