aboutsummaryrefslogtreecommitdiff
path: root/weed/command/iam.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-03-15 22:28:18 -0700
committerchrislu <chris.lu@gmail.com>2022-03-15 22:28:18 -0700
commit3639cad69cf58f7161aff2a639829c195d08ec30 (patch)
tree9f45239b5ef240a36f22b428cbb88438c551ab2b /weed/command/iam.go
parentfbc9f0eb64346fdfcdb70e43bedec068f1447c64 (diff)
downloadseaweedfs-3639cad69cf58f7161aff2a639829c195d08ec30.tar.xz
seaweedfs-3639cad69cf58f7161aff2a639829c195d08ec30.zip
master, filer, s3: also listen to "localhost" in addition to specific ip address
related to https://github.com/chrislusf/seaweedfs/issues/1937
Diffstat (limited to 'weed/command/iam.go')
-rw-r--r--weed/command/iam.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/weed/command/iam.go b/weed/command/iam.go
index 8fb14be06..88b17b1a2 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")
}
@@ -81,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)
}