diff options
Diffstat (limited to 'weed/command/s3.go')
| -rw-r--r-- | weed/command/s3.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/weed/command/s3.go b/weed/command/s3.go index ee726fcec..467da73fd 100644 --- a/weed/command/s3.go +++ b/weed/command/s3.go @@ -34,12 +34,13 @@ type S3Options struct { metricsHttpPort *int allowEmptyFolder *bool auditLogConfig *string + localFilerSocket *string } func init() { cmdS3.Run = runS3 // break init cycle s3StandaloneOptions.filer = cmdS3.Flag.String("filer", "localhost:8888", "filer server address") - s3StandaloneOptions.bindIp = cmdS3.Flag.String("ip.bind", "", "ip address to bind to") + s3StandaloneOptions.bindIp = cmdS3.Flag.String("ip.bind", "", "ip address to bind to. Default to localhost.") s3StandaloneOptions.port = cmdS3.Flag.Int("port", 8333, "s3 server http listen port") s3StandaloneOptions.domainName = cmdS3.Flag.String("domainName", "", "suffix of the host name in comma separated list, {bucket}.{domainName}") s3StandaloneOptions.config = cmdS3.Flag.String("config", "", "path to the config file") @@ -184,6 +185,7 @@ func (s3opt *S3Options) startS3Server() bool { BucketsPath: filerBucketsPath, GrpcDialOption: grpcDialOption, AllowEmptyFolder: *s3opt.allowEmptyFolder, + LocalFilerSocket: s3opt.localFilerSocket, }) if s3ApiServer_err != nil { glog.Fatalf("S3 API Server startup error: %v", s3ApiServer_err) @@ -191,8 +193,12 @@ func (s3opt *S3Options) startS3Server() bool { httpS := &http.Server{Handler: router} + if *s3opt.bindIp == "" { + *s3opt.bindIp = "localhost" + } + listenAddress := fmt.Sprintf("%s:%d", *s3opt.bindIp, *s3opt.port) - s3ApiListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second) + s3ApiListener, s3ApiLocalListner, err := util.NewIpAndLocalListeners(*s3opt.bindIp, *s3opt.port, time.Duration(10)*time.Second) if err != nil { glog.Fatalf("S3 API Server listener on %s error: %v", listenAddress, err) } @@ -206,11 +212,25 @@ func (s3opt *S3Options) startS3Server() bool { if *s3opt.tlsPrivateKey != "" { glog.V(0).Infof("Start Seaweed S3 API Server %s at https port %d", util.Version(), *s3opt.port) + if s3ApiLocalListner != nil { + go func() { + if err = httpS.ServeTLS(s3ApiLocalListner, *s3opt.tlsCertificate, *s3opt.tlsPrivateKey); err != nil { + glog.Fatalf("S3 API Server Fail to serve: %v", err) + } + }() + } if err = httpS.ServeTLS(s3ApiListener, *s3opt.tlsCertificate, *s3opt.tlsPrivateKey); err != nil { glog.Fatalf("S3 API Server Fail to serve: %v", err) } } else { glog.V(0).Infof("Start Seaweed S3 API Server %s at http port %d", util.Version(), *s3opt.port) + if s3ApiLocalListner != nil { + go func() { + if err = httpS.Serve(s3ApiLocalListner); err != nil { + glog.Fatalf("S3 API Server Fail to serve: %v", err) + } + }() + } if err = httpS.Serve(s3ApiListener); err != nil { glog.Fatalf("S3 API Server Fail to serve: %v", err) } |
