From 6f678bad38da13ccad0e1f5223c8e1b5b0dcedbc Mon Sep 17 00:00:00 2001 From: Caio Almeida Date: Thu, 12 Dec 2024 20:20:47 -0300 Subject: [PATCH] chore: supporting the listen-address parameter Signed-off-by: Caio Almeida --- cmd/db-manager/v1beta1/main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/db-manager/v1beta1/main.go b/cmd/db-manager/v1beta1/main.go index 17f949f0690..165b93fd8aa 100644 --- a/cmd/db-manager/v1beta1/main.go +++ b/cmd/db-manager/v1beta1/main.go @@ -35,7 +35,7 @@ import ( ) const ( - port = "0.0.0.0:6789" + defaultListenAddress = "0.0.0.0:6789" defaultConnectTimeout = time.Second * 60 ) @@ -90,7 +90,9 @@ func (s *server) Check(ctx context.Context, in *health_pb.HealthCheckRequest) (* func main() { var connectTimeout time.Duration + var listenAddress string flag.DurationVar(&connectTimeout, "connect-timeout", defaultConnectTimeout, "Timeout before calling error during database connection. (e.g. 120s)") + flag.StringVar(&listenAddress, "listen-address", defaultListenAddress, "The network interface or IP address on which a service or application is configured to receive incoming connections. (e.g. 0.0.0.0:6789)") flag.Parse() var err error @@ -104,13 +106,13 @@ func main() { klog.Fatalf("Failed to open db connection: %v", err) } dbIf.DBInit() - listener, err := net.Listen("tcp", port) + listener, err := net.Listen("tcp", listenAddress) if err != nil { klog.Fatalf("Failed to listen: %v", err) } size := 1<<31 - 1 - klog.Infof("Start Katib manager: %s", port) + klog.Infof("Start Katib manager: %s", listenAddress) s := grpc.NewServer(grpc.MaxRecvMsgSize(size), grpc.MaxSendMsgSize(size)) api_pb.RegisterDBManagerServer(s, &server{}) health_pb.RegisterHealthServer(s, &server{})