From 19eb83d55d7ffe93f12850eae2bd55253b4c14be Mon Sep 17 00:00:00 2001 From: zjcyl Date: Mon, 13 May 2024 23:28:40 +0800 Subject: [PATCH] Update prober.go Add a user-defined health check port --- care/prober.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/care/prober.go b/care/prober.go index 1c0246a..736f881 100644 --- a/care/prober.go +++ b/care/prober.go @@ -37,6 +37,7 @@ type Prober interface { type httpProber struct { HealthPath string HealthScheme string + HealthPort int Method string Headers map[string]string Body string @@ -51,6 +52,7 @@ type httpProber struct { func (p *httpProber) RegisterFlags(fs *pflag.FlagSet) { fs.StringVar(&p.HealthPath, "health-path", "/healthz", "url path to probed") fs.StringVar(&p.HealthScheme, "health-schem", "https", "http scheme for prober") + fs.IntVar(&p.HealthPort, "health-port", int, "http port for prober") fs.StringVar(&p.Method, "health-req-method", "GET", "http request method") fs.StringVar(&p.Body, "health-req-body", "", "body to send for health checker") fs.StringToStringVar(&p.Headers, "health-req-headers", map[string]string{}, "http request headers") @@ -83,6 +85,7 @@ func (p *httpProber) Probe(host, port string) error { }, } } + if p.HealthPort != nil { port = p.HealthPort } uri := &url.URL{ Scheme: p.HealthScheme, Host: net.JoinHostPort(host, port),