func runMaster(cmd *Command, args []string) bool { if *mMaxCpu < 1 { *mMaxCpu = runtime.NumCPU() } runtime.GOMAXPROCS(*mMaxCpu) topo = topology.NewTopology("topo", *confFile, *metaFolder, "weed", uint64(*volumeSizeLimitMB)*1024*1024, *mpulse) vg = replication.NewDefaultVolumeGrowth() log.Println("Volume Size Limit is", *volumeSizeLimitMB, "MB") http.HandleFunc("/dir/assign", dirAssignHandler) http.HandleFunc("/dir/lookup", dirLookupHandler) http.HandleFunc("/dir/join", dirJoinHandler) http.HandleFunc("/dir/status", dirStatusHandler) http.HandleFunc("/vol/grow", volumeGrowHandler) http.HandleFunc("/vol/status", volumeStatusHandler) http.HandleFunc("/vol/vacuum", volumeVacuumHandler) http.HandleFunc("/", redirectHandler) topo.StartRefreshWritableVolumes(*garbageThreshold) log.Println("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport)) srv := &http.Server{ Addr: ":" + strconv.Itoa(*mport), Handler: http.DefaultServeMux, ReadTimeout: time.Duration(*mReadTimeout) * time.Second, } e := srv.ListenAndServe() if e != nil { log.Fatalf("Fail to start:%s", e.Error()) } return true }
func runMaster(cmd *Command, args []string) bool { if *mMaxCpu < 1 { *mMaxCpu = runtime.NumCPU() } runtime.GOMAXPROCS(*mMaxCpu) if *masterWhiteListOption != "" { masterWhiteList = strings.Split(*masterWhiteListOption, ",") } var e error if topo, e = topology.NewTopology("topo", *confFile, *metaFolder, "weed", uint64(*volumeSizeLimitMB)*1024*1024, *mpulse); e != nil { glog.Fatalf("cannot create topology:%s", e) } vg = replication.NewDefaultVolumeGrowth() glog.V(0).Infoln("Volume Size Limit is", *volumeSizeLimitMB, "MB") http.HandleFunc("/dir/assign", secure(masterWhiteList, dirAssignHandler)) http.HandleFunc("/dir/lookup", secure(masterWhiteList, dirLookupHandler)) http.HandleFunc("/dir/join", secure(masterWhiteList, dirJoinHandler)) http.HandleFunc("/dir/status", secure(masterWhiteList, dirStatusHandler)) http.HandleFunc("/vol/grow", secure(masterWhiteList, volumeGrowHandler)) http.HandleFunc("/vol/status", secure(masterWhiteList, volumeStatusHandler)) http.HandleFunc("/vol/vacuum", secure(masterWhiteList, volumeVacuumHandler)) http.HandleFunc("/submit", secure(masterWhiteList, submitFromMasterServerHandler)) http.HandleFunc("/", redirectHandler) topo.StartRefreshWritableVolumes(*garbageThreshold) glog.V(0).Infoln("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport)) srv := &http.Server{ Addr: ":" + strconv.Itoa(*mport), Handler: http.DefaultServeMux, ReadTimeout: time.Duration(*mReadTimeout) * time.Second, } e = srv.ListenAndServe() if e != nil { glog.Fatalf("Fail to start:%s", e) } return true }