@@ -20,8 +20,6 @@ import (
2020 "context"
2121 "flag"
2222 "fmt"
23- "github.com/zilliztech/woodpecker/common/logger"
24- "github.com/zilliztech/woodpecker/common/tracer"
2523 "log"
2624 "net"
2725 "os"
@@ -32,7 +30,9 @@ import (
3230 "github.com/zilliztech/woodpecker/cmd/external"
3331 "github.com/zilliztech/woodpecker/common/config"
3432 commonhttp "github.com/zilliztech/woodpecker/common/http"
33+ "github.com/zilliztech/woodpecker/common/logger"
3534 "github.com/zilliztech/woodpecker/common/membership"
35+ "github.com/zilliztech/woodpecker/common/tracer"
3636 "github.com/zilliztech/woodpecker/server"
3737)
3838
@@ -54,43 +54,6 @@ func parseAdvertiseAddr(addrPort string) (string, int, error) {
5454
5555 return host , port , nil
5656}
57-
58- // resolveAdvertiseAddr resolves hostname to IP address if needed
59- func resolveAdvertiseAddr (addr string ) string {
60- if addr == "" {
61- return ""
62- }
63-
64- // Check if it's already an IP address
65- if ip := net .ParseIP (addr ); ip != nil {
66- return addr
67- }
68-
69- // Try to resolve hostname to IP
70- ips , err := net .LookupIP (addr )
71- if err != nil {
72- log .Printf ("Warning: Failed to resolve hostname '%s' to IP: %v. Using as-is." , addr , err )
73- return addr
74- }
75-
76- // Prefer IPv4 address
77- for _ , ip := range ips {
78- if ipv4 := ip .To4 (); ipv4 != nil {
79- log .Printf ("Resolved hostname '%s' to IPv4: %s" , addr , ipv4 .String ())
80- return ipv4 .String ()
81- }
82- }
83-
84- // Fallback to first IP (could be IPv6)
85- if len (ips ) > 0 {
86- log .Printf ("Resolved hostname '%s' to IP: %s" , addr , ips [0 ].String ())
87- return ips [0 ].String ()
88- }
89-
90- log .Printf ("Warning: No IP found for hostname '%s'. Using as-is." , addr )
91- return addr
92- }
93-
9457func main () {
9558 var (
9659 servicePort = flag .Int ("service-port" , 18080 , "service port" )
@@ -180,7 +143,6 @@ func main() {
180143 } else {
181144 advertisePort = * gossipPort
182145 }
183- resourceAdvertiseGossipAddrStr := resolveAdvertiseAddr (advertiseAddrStr )
184146
185147 if * advertiseServiceAddr != "" {
186148 addr , port , err := parseAdvertiseAddr (* advertiseServiceAddr )
@@ -198,10 +160,10 @@ func main() {
198160 NodeID : * nodeName ,
199161 BindPort : * gossipPort ,
200162 ServicePort : * servicePort ,
201- AdvertiseAddr : resourceAdvertiseGossipAddrStr , // Gossip advertise address (IP only)
202- AdvertisePort : advertisePort , // Gossip advertise port
203- AdvertiseServiceAddr : advertiseServiceAddrStr , // Service advertise address (hostname only)
204- AdvertiseServicePort : advertiseServicePort , // Service advertise port
163+ AdvertiseAddr : advertiseAddrStr , // Gossip advertise address (IP only)
164+ AdvertisePort : advertisePort , // Gossip advertise port
165+ AdvertiseServiceAddr : advertiseServiceAddrStr , // Service advertise address (hostname only)
166+ AdvertiseServicePort : advertiseServicePort , // Service advertise port
205167 ResourceGroup : * resourceGroup ,
206168 AZ : * availabilityZone ,
207169 Tags : map [string ]string {"role" : "logstore" },
@@ -217,10 +179,10 @@ func main() {
217179 }
218180
219181 // Start HTTP server for metrics, health check, and pprof
220- if err := commonhttp .Start (cfg ); err != nil {
182+ if err := commonhttp .Start (cfg , srv . GetServerNodeMemberlistStatus ); err != nil {
221183 log .Fatalf ("Failed to start HTTP server: %v" , err )
222184 }
223- log .Printf ("HTTP server started on port %s (metrics, health, pprof)" , commonhttp .DefaultListenPort )
185+ log .Printf ("HTTP server started on port %s (metrics, health, pprof, admin )" , commonhttp .DefaultListenPort )
224186
225187 log .Printf ("Starting Woodpecker Server:" )
226188 log .Printf (" Node Name: %s" , * nodeName )
0 commit comments