fixed healthcheck failed to disable and nil dereference

This commit is contained in:
yusing
2024-10-19 00:13:55 +08:00
parent 53557e38b6
commit b296fb2965
11 changed files with 60 additions and 20 deletions

View File

@@ -106,9 +106,12 @@ func (r *HTTPRoute) Start(providerSubtask task.Task) E.NestedError {
httpRoutesMu.Lock()
defer httpRoutesMu.Unlock()
if r.HealthCheck.Disabled && (entry.UseLoadBalance(r) || entry.UseIdleWatcher(r)) {
if !entry.UseHealthCheck(r) && (entry.UseLoadBalance(r) || entry.UseIdleWatcher(r)) {
logrus.Warnf("%s.healthCheck.disabled cannot be false when loadbalancer or idlewatcher is enabled", r.Alias)
r.HealthCheck.Disabled = true
if r.HealthCheck == nil {
r.HealthCheck = new(health.HealthCheckConfig)
}
r.HealthCheck.Disable = true
}
switch {
@@ -121,6 +124,7 @@ func (r *HTTPRoute) Start(providerSubtask task.Task) E.NestedError {
r.handler = waker
r.HealthMon = waker
case entry.UseHealthCheck(r):
logrus.Debugf("%s health check: %+v", r.Alias, r.HealthCheck)
r.HealthMon = health.NewHTTPHealthMonitor(r.TargetURL(), r.HealthCheck, r.rp.Transport)
}
r.task = providerSubtask