change CLI option from publicIp to publicUrl

Now the publicUrl is free style text.
This commit is contained in:
chrislusf 2015-02-02 15:51:25 -08:00
parent cc724305b6
commit e381356af9
4 changed files with 16 additions and 33 deletions

View file

@ -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 <ip>|<server_name>")
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)
}()

View file

@ -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,

View file

@ -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 <ip|server_name>")
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,

View file

@ -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,