From e381356af975132d57b51e1923722b5413c9111e Mon Sep 17 00:00:00 2001 From: chrislusf Date: Mon, 2 Feb 2015 15:51:25 -0800 Subject: [PATCH] change CLI option from publicIp to publicUrl Now the publicUrl is free style text. --- go/weed/master.go | 13 ++++--------- go/weed/server.go | 16 ++++++---------- go/weed/volume.go | 16 +++++----------- go/weed/weed_server/volume_server.go | 4 +--- 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/go/weed/master.go b/go/weed/master.go index 13f6d7c43..af63d8c22 100644 --- a/go/weed/master.go +++ b/go/weed/master.go @@ -31,7 +31,6 @@ var ( mport = cmdMaster.Flag.Int("port", 9333, "http listen port") masterIp = cmdMaster.Flag.String("ip", "", "master listening ip address, default to listen on all network interfaces") masterBindIp = cmdMaster.Flag.String("ip.bind", "0.0.0.0", "ip address to bind to") - mPublicIp = cmdMaster.Flag.String("publicIp", "", "peer accessible |") metaFolder = cmdMaster.Flag.String("mdir", os.TempDir(), "data directory to store meta data") masterPeers = cmdMaster.Flag.String("peers", "", "other master nodes in comma separated ip:port list") volumeSizeLimitMB = cmdMaster.Flag.Uint("volumeSizeLimitMB", 30*1000, "Master stops directing writes to oversized volumes.") @@ -76,19 +75,15 @@ func runMaster(cmd *Command, args []string) bool { go func() { time.Sleep(100 * time.Millisecond) - if *mPublicIp == "" { - if *masterIp == "" { - *mPublicIp = "localhost" - } else { - *mPublicIp = *masterIp - } + if *masterIp == "" { + *masterIp = "localhost" } - myPublicMasterAddress := *mPublicIp + ":" + strconv.Itoa(*mport) + myMasterAddress := *masterIp + ":" + strconv.Itoa(*mport) var peers []string if *masterPeers != "" { peers = strings.Split(*masterPeers, ",") } - raftServer := weed_server.NewRaftServer(r, peers, myPublicMasterAddress, *metaFolder, ms.Topo, *mpulse) + raftServer := weed_server.NewRaftServer(r, peers, myMasterAddress, *metaFolder, ms.Topo, *mpulse) ms.SetRaftServer(raftServer) }() diff --git a/go/weed/server.go b/go/weed/server.go index 16b809c53..f7cbab55b 100644 --- a/go/weed/server.go +++ b/go/weed/server.go @@ -48,7 +48,7 @@ var cmdServer = &Command{ var ( serverIp = cmdServer.Flag.String("ip", "", "ip or server name") - serverPublicIp = cmdServer.Flag.String("publicIp", "", "ip or server name") + serverPublicUrl = cmdServer.Flag.String("publicUrl", "", "publicly accessible address") serverBindIp = cmdServer.Flag.String("ip.bind", "0.0.0.0", "ip address to bind to") serverMaxCpu = cmdServer.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs") serverTimeout = cmdServer.Flag.Int("idleTimeout", 10, "connection idle seconds") @@ -99,19 +99,15 @@ func runServer(cmd *Command, args []string) bool { defer pprof.StopCPUProfile() } - if *serverPublicIp == "" { - if *serverIp == "" { - *serverPublicIp = "localhost" - } else { - *serverPublicIp = *serverIp - } + if *serverIp == "" { + *serverIp = "localhost" } if *filerOptions.redirectOnRead { *isStartingFiler = true } - *filerOptions.master = *serverPublicIp + ":" + strconv.Itoa(*masterPort) + *filerOptions.master = *serverIp + ":" + strconv.Itoa(*masterPort) if *filerOptions.defaultReplicaPlacement == "" { *filerOptions.defaultReplicaPlacement = *masterDefaultReplicaPlacement @@ -207,7 +203,7 @@ func runServer(cmd *Command, args []string) bool { go func() { raftWaitForMaster.Wait() time.Sleep(100 * time.Millisecond) - myAddress := *serverPublicIp + ":" + strconv.Itoa(*masterPort) + myAddress := *serverIp + ":" + strconv.Itoa(*masterPort) var peers []string if *serverPeers != "" { peers = strings.Split(*serverPeers, ",") @@ -227,7 +223,7 @@ func runServer(cmd *Command, args []string) bool { time.Sleep(100 * time.Millisecond) r := http.NewServeMux() volumeServer := weed_server.NewVolumeServer(r, r, - *serverIp, *volumePort, *volumeAdminPort, *serverPublicIp, + *serverIp, *volumePort, *volumeAdminPort, *serverPublicUrl, folders, maxCounts, *serverIp+":"+strconv.Itoa(*masterPort), *volumePulse, *serverDataCenter, *serverRack, serverWhiteList, *volumeFixJpgOrientation, diff --git a/go/weed/volume.go b/go/weed/volume.go index df1d603ac..df3974c8c 100644 --- a/go/weed/volume.go +++ b/go/weed/volume.go @@ -23,7 +23,7 @@ type VolumeServerOptions struct { folders []string folderMaxLimits []int ip *string - publicIp *string + publicUrl *string bindIp *string master *string pulseSeconds *int @@ -40,7 +40,7 @@ func init() { v.port = cmdVolume.Flag.Int("port", 8080, "http listen port") v.adminPort = cmdVolume.Flag.Int("port.admin", 0, "admin port to talk with master and other volume servers") v.ip = cmdVolume.Flag.String("ip", "", "ip or server name") - v.publicIp = cmdVolume.Flag.String("publicIp", "", "Publicly accessible ") + v.publicUrl = cmdVolume.Flag.String("publicUrl", "", "Publicly accessible address") v.bindIp = cmdVolume.Flag.String("ip.bind", "0.0.0.0", "ip address to bind to") v.master = cmdVolume.Flag.String("mserver", "localhost:9333", "master server location") v.pulseSeconds = cmdVolume.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats, must be smaller than or equal to the master's setting") @@ -95,14 +95,8 @@ func runVolume(cmd *Command, args []string) bool { v.whiteList = strings.Split(*volumeWhiteListOption, ",") } - //derive default public ip address - if *v.publicIp == "" { - if *v.ip == "" { - *v.ip = "127.0.0.1" - *v.publicIp = "localhost" - } else { - *v.publicIp = *v.ip - } + if *v.ip == "" { + *v.ip = "127.0.0.1" } if *v.adminPort == 0 { @@ -117,7 +111,7 @@ func runVolume(cmd *Command, args []string) bool { } volumeServer := weed_server.NewVolumeServer(publicMux, adminMux, - *v.ip, *v.port, *v.adminPort, *v.publicIp, + *v.ip, *v.port, *v.adminPort, *v.publicUrl, v.folders, v.folderMaxLimits, *v.master, *v.pulseSeconds, *v.dataCenter, *v.rack, v.whiteList, diff --git a/go/weed/weed_server/volume_server.go b/go/weed/weed_server/volume_server.go index 8846c4794..f3ad2974d 100644 --- a/go/weed/weed_server/volume_server.go +++ b/go/weed/weed_server/volume_server.go @@ -3,7 +3,6 @@ package weed_server import ( "math/rand" "net/http" - "strconv" "time" "github.com/chrislusf/weed-fs/go/glog" @@ -23,13 +22,12 @@ type VolumeServer struct { } func NewVolumeServer(publicMux, adminMux *http.ServeMux, ip string, - port, adminPort int, publicIp string, + port, adminPort int, publicUrl string, folders []string, maxCounts []int, masterNode string, pulseSeconds int, dataCenter string, rack string, whiteList []string, fixJpgOrientation bool) *VolumeServer { - publicUrl := publicIp + ":" + strconv.Itoa(port) vs := &VolumeServer{ masterNode: masterNode, pulseSeconds: pulseSeconds,