Skip to content

Commit

Permalink
chore: supporting the listen-address parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
caiofralmeida committed Dec 12, 2024
1 parent 3363964 commit 926cd93
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/db-manager/v1beta1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
)

const (
port = "0.0.0.0:6789"
defaultListenAddress = "0.0.0.0:6789"
defaultConnectTimeout = time.Second * 60
)

Expand Down Expand Up @@ -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
Expand All @@ -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{})
Expand Down

0 comments on commit 926cd93

Please sign in to comment.