aboutsummaryrefslogtreecommitdiff
path: root/weed/command/iam.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/command/iam.go')
-rw-r--r--weed/command/iam.go34
1 files changed, 20 insertions, 14 deletions
diff --git a/weed/command/iam.go b/weed/command/iam.go
index ed4eea543..968d23095 100644
--- a/weed/command/iam.go
+++ b/weed/command/iam.go
@@ -22,6 +22,7 @@ var (
type IamOptions struct {
filer *string
masters *string
+ ip *string
port *int
}
@@ -29,6 +30,7 @@ func init() {
cmdIam.Run = runIam // break init cycle
iamStandaloneOptions.filer = cmdIam.Flag.String("filer", "localhost:8888", "filer server address")
iamStandaloneOptions.masters = cmdIam.Flag.String("master", "localhost:9333", "comma-separated master servers")
+ iamStandaloneOptions.ip = cmdIam.Flag.String("ip", util.DetectedHostAddress(), "iam server http listen ip address")
iamStandaloneOptions.port = cmdIam.Flag.Int("port", 8111, "iam server http listen port")
}
@@ -43,38 +45,35 @@ func runIam(cmd *Command, args []string) bool {
}
func (iamopt *IamOptions) startIamServer() bool {
- filerGrpcAddress, err := pb.ParseServerToGrpcAddress(*iamopt.filer)
- if err != nil {
- glog.Fatal(err)
- return false
- }
+ filerAddress := pb.ServerAddress(*iamopt.filer)
util.LoadConfiguration("security", false)
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
for {
- err = pb.WithGrpcFilerClient(filerGrpcAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
+ err := pb.WithGrpcFilerClient(false, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
if err != nil {
- return fmt.Errorf("get filer %s configuration: %v", filerGrpcAddress, err)
+ return fmt.Errorf("get filer %s configuration: %v", filerAddress, err)
}
glog.V(0).Infof("IAM read filer configuration: %s", resp)
return nil
})
if err != nil {
- glog.V(0).Infof("wait to connect to filer %s grpc address %s", *iamopt.filer, filerGrpcAddress)
+ glog.V(0).Infof("wait to connect to filer %s grpc address %s", *iamopt.filer, filerAddress.ToGrpcAddress())
time.Sleep(time.Second)
} else {
- glog.V(0).Infof("connected to filer %s grpc address %s", *iamopt.filer, filerGrpcAddress)
+ glog.V(0).Infof("connected to filer %s grpc address %s", *iamopt.filer, filerAddress.ToGrpcAddress())
break
}
}
+ masters := pb.ServerAddresses(*iamopt.masters).ToAddressMap()
router := mux.NewRouter().SkipClean(true)
_, iamApiServer_err := iamapi.NewIamApiServer(router, &iamapi.IamServerOption{
- Filer: *iamopt.filer,
- Port: *iamopt.port,
- FilerGrpcAddress: filerGrpcAddress,
- GrpcDialOption: grpcDialOption,
+ Masters: masters,
+ Filer: filerAddress,
+ Port: *iamopt.port,
+ GrpcDialOption: grpcDialOption,
})
glog.V(0).Info("NewIamApiServer created")
if iamApiServer_err != nil {
@@ -84,12 +83,19 @@ func (iamopt *IamOptions) startIamServer() bool {
httpS := &http.Server{Handler: router}
listenAddress := fmt.Sprintf(":%d", *iamopt.port)
- iamApiListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second)
+ iamApiListener, iamApiLocalListener, err := util.NewIpAndLocalListeners(*iamopt.ip, *iamopt.port, time.Duration(10)*time.Second)
if err != nil {
glog.Fatalf("IAM API Server listener on %s error: %v", listenAddress, err)
}
glog.V(0).Infof("Start Seaweed IAM API Server %s at http port %d", util.Version(), *iamopt.port)
+ if iamApiLocalListener != nil {
+ go func() {
+ if err = httpS.Serve(iamApiLocalListener); err != nil {
+ glog.Errorf("IAM API Server Fail to serve: %v", err)
+ }
+ }()
+ }
if err = httpS.Serve(iamApiListener); err != nil {
glog.Fatalf("IAM API Server Fail to serve: %v", err)
}