diff options
Diffstat (limited to 'weed/command/filer.go')
| -rw-r--r-- | weed/command/filer.go | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/weed/command/filer.go b/weed/command/filer.go index 2e1c9d1dc..b90d88edc 100644 --- a/weed/command/filer.go +++ b/weed/command/filer.go @@ -19,6 +19,7 @@ type FilerOptions struct { master *string ip *string port *int + publicPort *int collection *string defaultReplicaPlacement *string dir *string @@ -40,6 +41,7 @@ func init() { f.collection = cmdFiler.Flag.String("collection", "", "all data will be stored in this collection") f.ip = cmdFiler.Flag.String("ip", "", "filer server http listen ip address") f.port = cmdFiler.Flag.Int("port", 8888, "filer server http listen port") + f.publicPort = cmdFiler.Flag.Int("port.public", 0, "port opened to public") f.dir = cmdFiler.Flag.String("dir", os.TempDir(), "directory to store meta data") f.defaultReplicaPlacement = cmdFiler.Flag.String("defaultReplicaPlacement", "000", "default replication type if not specified") f.redirectOnRead = cmdFiler.Flag.Bool("redirectOnRead", false, "whether proxy or redirect to volume server during file GET request") @@ -83,21 +85,50 @@ func runFiler(cmd *Command, args []string) bool { glog.Fatalf("Check Meta Folder (-dir) Writable %s : %s", *f.dir, err) } + f.start() + + return true +} + +func (fo *FilerOptions) start() { + defaultMux := http.NewServeMux() - _, nfs_err := weed_server.NewFilerServer(defaultMux, *f.ip, *f.port, *f.master, *f.dir, *f.collection, - *f.defaultReplicaPlacement, *f.redirectOnRead, *f.disableDirListing, - *f.confFile, - *f.maxMB, - *f.secretKey, - *f.cassandra_server, *f.cassandra_keyspace, - *f.redis_server, *f.redis_password, *f.redis_database, + publicVolumeMux := defaultMux + + if *fo.publicPort != 0 { + publicVolumeMux = http.NewServeMux() + } + + _, nfs_err := weed_server.NewFilerServer(defaultMux, publicVolumeMux, + *fo.ip, *fo.port, *fo.master, *fo.dir, *fo.collection, + *fo.defaultReplicaPlacement, *fo.redirectOnRead, *fo.disableDirListing, + *fo.confFile, + *fo.maxMB, + *fo.secretKey, + *fo.cassandra_server, *fo.cassandra_keyspace, + *fo.redis_server, *fo.redis_password, *fo.redis_database, ) if nfs_err != nil { glog.Fatalf("Filer startup error: %v", nfs_err) } - glog.V(0).Infoln("Start Seaweed Filer", util.VERSION, "at port", strconv.Itoa(*f.port)) + + if *fo.publicPort != 0 { + publicListeningAddress := *fo.ip + ":" + strconv.Itoa(*fo.publicPort) + glog.V(0).Infoln("Start Seaweed filer server", util.VERSION, "public at", publicListeningAddress) + publicListener, e := util.NewListener(publicListeningAddress, 0) + if e != nil { + glog.Fatalf("Filer server public listener error on port %d:%v", *fo.publicPort, e) + } + go func() { + if e := http.Serve(publicListener, publicVolumeMux); e != nil { + glog.Fatalf("Volume server fail to serve public: %v", e) + } + }() + } + + glog.V(0).Infoln("Start Seaweed Filer", util.VERSION, "at port", strconv.Itoa(*fo.port)) filerListener, e := util.NewListener( - ":"+strconv.Itoa(*f.port), + ":"+strconv.Itoa(*fo.port), time.Duration(10)*time.Second, ) if e != nil { @@ -107,5 +138,4 @@ func runFiler(cmd *Command, args []string) bool { glog.Fatalf("Filer Fail to serve: %v", e) } - return true } |
