Add optional admin port to volume server, to seperate admin operations from normal file operations.
This commit is contained in:
@@ -64,6 +64,7 @@ var (
|
||||
masterConfFile = cmdServer.Flag.String("master.conf", "/etc/weedfs/weedfs.conf", "xml configuration file")
|
||||
masterDefaultReplicaPlacement = cmdServer.Flag.String("master.defaultReplicaPlacement", "000", "Default replication type if not specified.")
|
||||
volumePort = cmdServer.Flag.Int("volume.port", 8080, "volume server http listen port")
|
||||
volumeAdminPort = cmdServer.Flag.Int("volume.port.admin", 0, "volume server admin port to talk with master and other volume servers")
|
||||
volumeDataFolders = cmdServer.Flag.String("dir", os.TempDir(), "directories to store data files. dir[,dir]...")
|
||||
volumeMaxDataVolumeCounts = cmdServer.Flag.String("volume.max", "7", "maximum numbers of volumes, count[,count]...")
|
||||
volumePulse = cmdServer.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")
|
||||
@@ -225,7 +226,9 @@ func runServer(cmd *Command, args []string) bool {
|
||||
volumeWait.Wait()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
r := http.NewServeMux()
|
||||
volumeServer := weed_server.NewVolumeServer(r, r, *serverIp, *volumePort, *serverPublicIp, folders, maxCounts,
|
||||
volumeServer := weed_server.NewVolumeServer(r, r,
|
||||
*serverIp, *volumePort, *volumeAdminPort, *serverPublicIp,
|
||||
folders, maxCounts,
|
||||
*serverIp+":"+strconv.Itoa(*masterPort), *volumePulse, *serverDataCenter, *serverRack,
|
||||
serverWhiteList, *volumeFixJpgOrientation,
|
||||
)
|
||||
|
||||
@@ -38,7 +38,7 @@ type VolumeServerOptions struct {
|
||||
func init() {
|
||||
cmdVolume.Run = runVolume // break init cycle
|
||||
v.port = cmdVolume.Flag.Int("port", 8080, "http listen port")
|
||||
v.adminPort = cmdVolume.Flag.Int("port.admin", 8443, "https admin port, active when SSL certs are specified. Not ready yet.")
|
||||
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.bindIp = cmdVolume.Flag.String("ip.bind", "0.0.0.0", "ip address to bind to")
|
||||
@@ -105,28 +105,50 @@ func runVolume(cmd *Command, args []string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
r := http.NewServeMux()
|
||||
if *v.adminPort == 0 {
|
||||
*v.adminPort = *v.port
|
||||
}
|
||||
isSeperatedAdminPort := *v.adminPort != *v.port
|
||||
|
||||
volumeServer := weed_server.NewVolumeServer(r, r, *v.ip, *v.port, *v.publicIp, v.folders, v.folderMaxLimits,
|
||||
publicMux := http.NewServeMux()
|
||||
adminMux := publicMux
|
||||
if isSeperatedAdminPort {
|
||||
adminMux = http.NewServeMux()
|
||||
}
|
||||
|
||||
volumeServer := weed_server.NewVolumeServer(publicMux, adminMux,
|
||||
*v.ip, *v.port, *v.adminPort, *v.publicIp,
|
||||
v.folders, v.folderMaxLimits,
|
||||
*v.master, *v.pulseSeconds, *v.dataCenter, *v.rack,
|
||||
v.whiteList,
|
||||
*v.fixJpgOrientation,
|
||||
)
|
||||
|
||||
listeningAddress := *v.bindIp + ":" + strconv.Itoa(*v.port)
|
||||
|
||||
glog.V(0).Infoln("Start Seaweed volume server", util.VERSION, "at", listeningAddress)
|
||||
|
||||
listener, e := util.NewListener(listeningAddress, time.Duration(*v.idleConnectionTimeout)*time.Second)
|
||||
if e != nil {
|
||||
glog.Fatalf("Volume server listener error:%v", e)
|
||||
}
|
||||
if isSeperatedAdminPort {
|
||||
adminListeningAddress := *v.bindIp + ":" + strconv.Itoa(*v.adminPort)
|
||||
glog.V(0).Infoln("Start Seaweed volume server", util.VERSION, "admin at", adminListeningAddress)
|
||||
adminListener, e := util.NewListener(adminListeningAddress, time.Duration(*v.idleConnectionTimeout)*time.Second)
|
||||
if e != nil {
|
||||
glog.Fatalf("Volume server listener error:%v", e)
|
||||
}
|
||||
go func() {
|
||||
if e := http.Serve(adminListener, adminMux); e != nil {
|
||||
glog.Fatalf("Volume server fail to serve admin: %v", e)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
OnInterrupt(func() {
|
||||
volumeServer.Shutdown()
|
||||
})
|
||||
|
||||
if e := http.Serve(listener, r); e != nil {
|
||||
if e := http.Serve(listener, publicMux); e != nil {
|
||||
glog.Fatalf("Volume server fail to serve: %v", e)
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -22,7 +22,9 @@ type VolumeServer struct {
|
||||
FixJpgOrientation bool
|
||||
}
|
||||
|
||||
func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string, port int, publicIp string, folders []string, maxCounts []int,
|
||||
func NewVolumeServer(publicMux, adminMux *http.ServeMux, ip string,
|
||||
port, adminPort int, publicIp string,
|
||||
folders []string, maxCounts []int,
|
||||
masterNode string, pulseSeconds int,
|
||||
dataCenter string, rack string,
|
||||
whiteList []string,
|
||||
@@ -35,7 +37,7 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string, port int, pu
|
||||
rack: rack,
|
||||
FixJpgOrientation: fixJpgOrientation,
|
||||
}
|
||||
vs.store = storage.NewStore(port, ip, publicUrl, folders, maxCounts)
|
||||
vs.store = storage.NewStore(port, adminPort, ip, publicUrl, folders, maxCounts)
|
||||
|
||||
vs.guard = security.NewGuard(whiteList, "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user