aboutsummaryrefslogtreecommitdiff
path: root/go/weed
diff options
context:
space:
mode:
Diffstat (limited to 'go/weed')
-rw-r--r--go/weed/server.go5
-rw-r--r--go/weed/volume.go34
-rw-r--r--go/weed/weed_server/volume_server.go6
3 files changed, 36 insertions, 9 deletions
diff --git a/go/weed/server.go b/go/weed/server.go
index 980c545b4..16b809c53 100644
--- a/go/weed/server.go
+++ b/go/weed/server.go
@@ -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,
)
diff --git a/go/weed/volume.go b/go/weed/volume.go
index 1dfd88576..df1d603ac 100644
--- a/go/weed/volume.go
+++ b/go/weed/volume.go
@@ -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
+
+ publicMux := http.NewServeMux()
+ adminMux := publicMux
+ if isSeperatedAdminPort {
+ adminMux = http.NewServeMux()
+ }
- volumeServer := weed_server.NewVolumeServer(r, r, *v.ip, *v.port, *v.publicIp, v.folders, v.folderMaxLimits,
+ 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
diff --git a/go/weed/weed_server/volume_server.go b/go/weed/weed_server/volume_server.go
index 0eb9daa0e..18856c554 100644
--- a/go/weed/weed_server/volume_server.go
+++ b/go/weed/weed_server/volume_server.go
@@ -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, "")