mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
s3: bind to a specific IP
fix https://github.com/chrislusf/seaweedfs/issues/2516
This commit is contained in:
parent
e526a299dc
commit
85c526c583
|
@ -138,6 +138,7 @@ func runFiler(cmd *Command, args []string) bool {
|
||||||
startDelay := time.Duration(2)
|
startDelay := time.Duration(2)
|
||||||
if *filerStartS3 {
|
if *filerStartS3 {
|
||||||
filerS3Options.filer = &filerAddress
|
filerS3Options.filer = &filerAddress
|
||||||
|
filerS3Options.bindIp = f.bindIp
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(startDelay * time.Second)
|
time.Sleep(startDelay * time.Second)
|
||||||
filerS3Options.startS3Server()
|
filerS3Options.startS3Server()
|
||||||
|
|
|
@ -25,6 +25,7 @@ var (
|
||||||
|
|
||||||
type S3Options struct {
|
type S3Options struct {
|
||||||
filer *string
|
filer *string
|
||||||
|
bindIp *string
|
||||||
port *int
|
port *int
|
||||||
config *string
|
config *string
|
||||||
domainName *string
|
domainName *string
|
||||||
|
@ -38,6 +39,7 @@ type S3Options struct {
|
||||||
func init() {
|
func init() {
|
||||||
cmdS3.Run = runS3 // break init cycle
|
cmdS3.Run = runS3 // break init cycle
|
||||||
s3StandaloneOptions.filer = cmdS3.Flag.String("filer", "localhost:8888", "filer server address")
|
s3StandaloneOptions.filer = cmdS3.Flag.String("filer", "localhost:8888", "filer server address")
|
||||||
|
s3StandaloneOptions.bindIp = cmdS3.Flag.String("ip.bind", "", "ip address to bind to")
|
||||||
s3StandaloneOptions.port = cmdS3.Flag.Int("port", 8333, "s3 server http listen port")
|
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.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")
|
s3StandaloneOptions.config = cmdS3.Flag.String("config", "", "path to the config file")
|
||||||
|
@ -189,7 +191,7 @@ func (s3opt *S3Options) startS3Server() bool {
|
||||||
|
|
||||||
httpS := &http.Server{Handler: router}
|
httpS := &http.Server{Handler: router}
|
||||||
|
|
||||||
listenAddress := fmt.Sprintf(":%d", *s3opt.port)
|
listenAddress := fmt.Sprintf("%s:%d", *s3opt.bindIp, *s3opt.port)
|
||||||
s3ApiListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second)
|
s3ApiListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("S3 API Server listener on %s error: %v", listenAddress, err)
|
glog.Fatalf("S3 API Server listener on %s error: %v", listenAddress, err)
|
||||||
|
|
|
@ -180,6 +180,7 @@ func runServer(cmd *Command, args []string) bool {
|
||||||
filerOptions.masters = pb.ServerAddresses(*masterOptions.peers).ToAddresses()
|
filerOptions.masters = pb.ServerAddresses(*masterOptions.peers).ToAddresses()
|
||||||
filerOptions.ip = serverIp
|
filerOptions.ip = serverIp
|
||||||
filerOptions.bindIp = serverBindIp
|
filerOptions.bindIp = serverBindIp
|
||||||
|
s3Options.bindIp = serverBindIp
|
||||||
serverOptions.v.ip = serverIp
|
serverOptions.v.ip = serverIp
|
||||||
serverOptions.v.bindIp = serverBindIp
|
serverOptions.v.bindIp = serverBindIp
|
||||||
serverOptions.v.masters = pb.ServerAddresses(*masterOptions.peers).ToAddresses()
|
serverOptions.v.masters = pb.ServerAddresses(*masterOptions.peers).ToAddresses()
|
||||||
|
|
Loading…
Reference in a new issue