mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
master: add option to disable http operations
This commit is contained in:
parent
572d986dee
commit
2812c14520
|
@ -47,6 +47,7 @@ var (
|
||||||
mMaxCpu = cmdMaster.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
|
mMaxCpu = cmdMaster.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
|
||||||
garbageThreshold = cmdMaster.Flag.Float64("garbageThreshold", 0.3, "threshold to vacuum and reclaim spaces")
|
garbageThreshold = cmdMaster.Flag.Float64("garbageThreshold", 0.3, "threshold to vacuum and reclaim spaces")
|
||||||
masterWhiteListOption = cmdMaster.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")
|
masterWhiteListOption = cmdMaster.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")
|
||||||
|
httpReadOnly = cmdMaster.Flag.Bool("httpReadOnly", false, "disable http operations, only gRPC operations are allowed.")
|
||||||
masterCpuProfile = cmdMaster.Flag.String("cpuprofile", "", "cpu profile output file")
|
masterCpuProfile = cmdMaster.Flag.String("cpuprofile", "", "cpu profile output file")
|
||||||
masterMemProfile = cmdMaster.Flag.String("memprofile", "", "memory profile output file")
|
masterMemProfile = cmdMaster.Flag.String("memprofile", "", "memory profile output file")
|
||||||
|
|
||||||
|
@ -78,6 +79,7 @@ func runMaster(cmd *Command, args []string) bool {
|
||||||
*volumeSizeLimitMB, *volumePreallocate,
|
*volumeSizeLimitMB, *volumePreallocate,
|
||||||
*mpulse, *defaultReplicaPlacement, *garbageThreshold,
|
*mpulse, *defaultReplicaPlacement, *garbageThreshold,
|
||||||
masterWhiteList,
|
masterWhiteList,
|
||||||
|
*httpReadOnly,
|
||||||
)
|
)
|
||||||
|
|
||||||
listeningAddress := *masterBindIp + ":" + strconv.Itoa(*mport)
|
listeningAddress := *masterBindIp + ":" + strconv.Itoa(*mport)
|
||||||
|
|
|
@ -60,6 +60,7 @@ var (
|
||||||
serverDataCenter = cmdServer.Flag.String("dataCenter", "", "current volume server's data center name")
|
serverDataCenter = cmdServer.Flag.String("dataCenter", "", "current volume server's data center name")
|
||||||
serverRack = cmdServer.Flag.String("rack", "", "current volume server's rack name")
|
serverRack = cmdServer.Flag.String("rack", "", "current volume server's rack name")
|
||||||
serverWhiteListOption = cmdServer.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")
|
serverWhiteListOption = cmdServer.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")
|
||||||
|
masterHttpReadOnly = cmdServer.Flag.Bool("master.httpReadOnly", false, "disable http operations, only gRPC operations are allowed.")
|
||||||
serverPeers = cmdServer.Flag.String("master.peers", "", "all master nodes in comma separated ip:masterPort list")
|
serverPeers = cmdServer.Flag.String("master.peers", "", "all master nodes in comma separated ip:masterPort list")
|
||||||
serverGarbageThreshold = cmdServer.Flag.Float64("garbageThreshold", 0.3, "threshold to vacuum and reclaim spaces")
|
serverGarbageThreshold = cmdServer.Flag.Float64("garbageThreshold", 0.3, "threshold to vacuum and reclaim spaces")
|
||||||
masterPort = cmdServer.Flag.Int("master.port", 9333, "master server http listen port")
|
masterPort = cmdServer.Flag.Int("master.port", 9333, "master server http listen port")
|
||||||
|
@ -171,7 +172,7 @@ func runServer(cmd *Command, args []string) bool {
|
||||||
ms := weed_server.NewMasterServer(r, *masterPort, *masterMetaFolder,
|
ms := weed_server.NewMasterServer(r, *masterPort, *masterMetaFolder,
|
||||||
*masterVolumeSizeLimitMB, *masterVolumePreallocate,
|
*masterVolumeSizeLimitMB, *masterVolumePreallocate,
|
||||||
*pulseSeconds, *masterDefaultReplicaPlacement, *serverGarbageThreshold,
|
*pulseSeconds, *masterDefaultReplicaPlacement, *serverGarbageThreshold,
|
||||||
serverWhiteList,
|
serverWhiteList, *masterHttpReadOnly,
|
||||||
)
|
)
|
||||||
|
|
||||||
glog.V(0).Infof("Start Seaweed Master %s at %s:%d", util.VERSION, *serverIp, *masterPort)
|
glog.V(0).Infof("Start Seaweed Master %s at %s:%d", util.VERSION, *serverIp, *masterPort)
|
||||||
|
|
|
@ -49,6 +49,7 @@ func NewMasterServer(r *mux.Router, port int, metaFolder string,
|
||||||
defaultReplicaPlacement string,
|
defaultReplicaPlacement string,
|
||||||
garbageThreshold float64,
|
garbageThreshold float64,
|
||||||
whiteList []string,
|
whiteList []string,
|
||||||
|
httpReadOnly bool,
|
||||||
) *MasterServer {
|
) *MasterServer {
|
||||||
|
|
||||||
v := viper.GetViper()
|
v := viper.GetViper()
|
||||||
|
@ -79,6 +80,7 @@ func NewMasterServer(r *mux.Router, port int, metaFolder string,
|
||||||
handleStaticResources2(r)
|
handleStaticResources2(r)
|
||||||
r.HandleFunc("/", ms.uiStatusHandler)
|
r.HandleFunc("/", ms.uiStatusHandler)
|
||||||
r.HandleFunc("/ui/index.html", ms.uiStatusHandler)
|
r.HandleFunc("/ui/index.html", ms.uiStatusHandler)
|
||||||
|
if (!httpReadOnly) {
|
||||||
r.HandleFunc("/dir/assign", ms.proxyToLeader(ms.guard.WhiteList(ms.dirAssignHandler)))
|
r.HandleFunc("/dir/assign", ms.proxyToLeader(ms.guard.WhiteList(ms.dirAssignHandler)))
|
||||||
r.HandleFunc("/dir/lookup", ms.proxyToLeader(ms.guard.WhiteList(ms.dirLookupHandler)))
|
r.HandleFunc("/dir/lookup", ms.proxyToLeader(ms.guard.WhiteList(ms.dirLookupHandler)))
|
||||||
r.HandleFunc("/dir/status", ms.proxyToLeader(ms.guard.WhiteList(ms.dirStatusHandler)))
|
r.HandleFunc("/dir/status", ms.proxyToLeader(ms.guard.WhiteList(ms.dirStatusHandler)))
|
||||||
|
@ -87,6 +89,7 @@ func NewMasterServer(r *mux.Router, port int, metaFolder string,
|
||||||
r.HandleFunc("/vol/status", ms.proxyToLeader(ms.guard.WhiteList(ms.volumeStatusHandler)))
|
r.HandleFunc("/vol/status", ms.proxyToLeader(ms.guard.WhiteList(ms.volumeStatusHandler)))
|
||||||
r.HandleFunc("/vol/vacuum", ms.proxyToLeader(ms.guard.WhiteList(ms.volumeVacuumHandler)))
|
r.HandleFunc("/vol/vacuum", ms.proxyToLeader(ms.guard.WhiteList(ms.volumeVacuumHandler)))
|
||||||
r.HandleFunc("/submit", ms.guard.WhiteList(ms.submitFromMasterServerHandler))
|
r.HandleFunc("/submit", ms.guard.WhiteList(ms.submitFromMasterServerHandler))
|
||||||
|
}
|
||||||
r.HandleFunc("/stats/health", ms.guard.WhiteList(statsHealthHandler))
|
r.HandleFunc("/stats/health", ms.guard.WhiteList(statsHealthHandler))
|
||||||
r.HandleFunc("/stats/counter", ms.guard.WhiteList(statsCounterHandler))
|
r.HandleFunc("/stats/counter", ms.guard.WhiteList(statsCounterHandler))
|
||||||
r.HandleFunc("/stats/memory", ms.guard.WhiteList(statsMemoryHandler))
|
r.HandleFunc("/stats/memory", ms.guard.WhiteList(statsMemoryHandler))
|
||||||
|
|
Loading…
Reference in a new issue