change CLI option from publicIp to publicUrl
Now the publicUrl is free style text.
This commit is contained in:
@@ -31,7 +31,6 @@ var (
|
|||||||
mport = cmdMaster.Flag.Int("port", 9333, "http listen port")
|
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")
|
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")
|
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")
|
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")
|
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.")
|
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() {
|
go func() {
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
if *mPublicIp == "" {
|
|
||||||
if *masterIp == "" {
|
if *masterIp == "" {
|
||||||
*mPublicIp = "localhost"
|
*masterIp = "localhost"
|
||||||
} else {
|
|
||||||
*mPublicIp = *masterIp
|
|
||||||
}
|
}
|
||||||
}
|
myMasterAddress := *masterIp + ":" + strconv.Itoa(*mport)
|
||||||
myPublicMasterAddress := *mPublicIp + ":" + strconv.Itoa(*mport)
|
|
||||||
var peers []string
|
var peers []string
|
||||||
if *masterPeers != "" {
|
if *masterPeers != "" {
|
||||||
peers = strings.Split(*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)
|
ms.SetRaftServer(raftServer)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ var cmdServer = &Command{
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
serverIp = cmdServer.Flag.String("ip", "", "ip or server name")
|
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")
|
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")
|
serverMaxCpu = cmdServer.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
|
||||||
serverTimeout = cmdServer.Flag.Int("idleTimeout", 10, "connection idle seconds")
|
serverTimeout = cmdServer.Flag.Int("idleTimeout", 10, "connection idle seconds")
|
||||||
@@ -99,19 +99,15 @@ func runServer(cmd *Command, args []string) bool {
|
|||||||
defer pprof.StopCPUProfile()
|
defer pprof.StopCPUProfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
if *serverPublicIp == "" {
|
|
||||||
if *serverIp == "" {
|
if *serverIp == "" {
|
||||||
*serverPublicIp = "localhost"
|
*serverIp = "localhost"
|
||||||
} else {
|
|
||||||
*serverPublicIp = *serverIp
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if *filerOptions.redirectOnRead {
|
if *filerOptions.redirectOnRead {
|
||||||
*isStartingFiler = true
|
*isStartingFiler = true
|
||||||
}
|
}
|
||||||
|
|
||||||
*filerOptions.master = *serverPublicIp + ":" + strconv.Itoa(*masterPort)
|
*filerOptions.master = *serverIp + ":" + strconv.Itoa(*masterPort)
|
||||||
|
|
||||||
if *filerOptions.defaultReplicaPlacement == "" {
|
if *filerOptions.defaultReplicaPlacement == "" {
|
||||||
*filerOptions.defaultReplicaPlacement = *masterDefaultReplicaPlacement
|
*filerOptions.defaultReplicaPlacement = *masterDefaultReplicaPlacement
|
||||||
@@ -207,7 +203,7 @@ func runServer(cmd *Command, args []string) bool {
|
|||||||
go func() {
|
go func() {
|
||||||
raftWaitForMaster.Wait()
|
raftWaitForMaster.Wait()
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
myAddress := *serverPublicIp + ":" + strconv.Itoa(*masterPort)
|
myAddress := *serverIp + ":" + strconv.Itoa(*masterPort)
|
||||||
var peers []string
|
var peers []string
|
||||||
if *serverPeers != "" {
|
if *serverPeers != "" {
|
||||||
peers = strings.Split(*serverPeers, ",")
|
peers = strings.Split(*serverPeers, ",")
|
||||||
@@ -227,7 +223,7 @@ func runServer(cmd *Command, args []string) bool {
|
|||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
r := http.NewServeMux()
|
r := http.NewServeMux()
|
||||||
volumeServer := weed_server.NewVolumeServer(r, r,
|
volumeServer := weed_server.NewVolumeServer(r, r,
|
||||||
*serverIp, *volumePort, *volumeAdminPort, *serverPublicIp,
|
*serverIp, *volumePort, *volumeAdminPort, *serverPublicUrl,
|
||||||
folders, maxCounts,
|
folders, maxCounts,
|
||||||
*serverIp+":"+strconv.Itoa(*masterPort), *volumePulse, *serverDataCenter, *serverRack,
|
*serverIp+":"+strconv.Itoa(*masterPort), *volumePulse, *serverDataCenter, *serverRack,
|
||||||
serverWhiteList, *volumeFixJpgOrientation,
|
serverWhiteList, *volumeFixJpgOrientation,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type VolumeServerOptions struct {
|
|||||||
folders []string
|
folders []string
|
||||||
folderMaxLimits []int
|
folderMaxLimits []int
|
||||||
ip *string
|
ip *string
|
||||||
publicIp *string
|
publicUrl *string
|
||||||
bindIp *string
|
bindIp *string
|
||||||
master *string
|
master *string
|
||||||
pulseSeconds *int
|
pulseSeconds *int
|
||||||
@@ -40,7 +40,7 @@ func init() {
|
|||||||
v.port = cmdVolume.Flag.Int("port", 8080, "http listen port")
|
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.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.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.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.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")
|
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, ",")
|
v.whiteList = strings.Split(*volumeWhiteListOption, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
//derive default public ip address
|
|
||||||
if *v.publicIp == "" {
|
|
||||||
if *v.ip == "" {
|
if *v.ip == "" {
|
||||||
*v.ip = "127.0.0.1"
|
*v.ip = "127.0.0.1"
|
||||||
*v.publicIp = "localhost"
|
|
||||||
} else {
|
|
||||||
*v.publicIp = *v.ip
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if *v.adminPort == 0 {
|
if *v.adminPort == 0 {
|
||||||
@@ -117,7 +111,7 @@ func runVolume(cmd *Command, args []string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
volumeServer := weed_server.NewVolumeServer(publicMux, adminMux,
|
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.folders, v.folderMaxLimits,
|
||||||
*v.master, *v.pulseSeconds, *v.dataCenter, *v.rack,
|
*v.master, *v.pulseSeconds, *v.dataCenter, *v.rack,
|
||||||
v.whiteList,
|
v.whiteList,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package weed_server
|
|||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/chrislusf/weed-fs/go/glog"
|
"github.com/chrislusf/weed-fs/go/glog"
|
||||||
@@ -23,13 +22,12 @@ type VolumeServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewVolumeServer(publicMux, adminMux *http.ServeMux, ip string,
|
func NewVolumeServer(publicMux, adminMux *http.ServeMux, ip string,
|
||||||
port, adminPort int, publicIp string,
|
port, adminPort int, publicUrl string,
|
||||||
folders []string, maxCounts []int,
|
folders []string, maxCounts []int,
|
||||||
masterNode string, pulseSeconds int,
|
masterNode string, pulseSeconds int,
|
||||||
dataCenter string, rack string,
|
dataCenter string, rack string,
|
||||||
whiteList []string,
|
whiteList []string,
|
||||||
fixJpgOrientation bool) *VolumeServer {
|
fixJpgOrientation bool) *VolumeServer {
|
||||||
publicUrl := publicIp + ":" + strconv.Itoa(port)
|
|
||||||
vs := &VolumeServer{
|
vs := &VolumeServer{
|
||||||
masterNode: masterNode,
|
masterNode: masterNode,
|
||||||
pulseSeconds: pulseSeconds,
|
pulseSeconds: pulseSeconds,
|
||||||
|
|||||||
Reference in New Issue
Block a user