Exemple #1
0
func (this *oss) Startmaster() error {
	api.InitAll(this.cm.metaHost, this.cm.metaPort, this.cm.user, this.cm.passwd, this.cm.db)
	if err := api.LoadChunkserverInfo(); err != nil {
		return fmt.Errorf("loadChunkserverInfo error: %v", err)
	}
	go api.MonitorTicker(5, 30)

	router := initRouter()
	http.Handle("/cm/", router)
	log.Infof("listen %s:%d", this.cm.serverHost, this.cm.serverPort)
	go func() {
		if err := http.ListenAndServe(this.cm.serverHost+":"+strconv.Itoa(this.cm.serverPort), nil); err != nil {
			log.Fatalf("listen error: %v", err)
		}
	}()
	runtime.Gosched()
	return nil
}
Exemple #2
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	var serverHost = flag.String("h", "0.0.0.0", "chunkmaster listen ip")
	var serverPort = flag.Int("p", 8099, "chunkmaster listen port")
	var metaHost = flag.String("dh", "127.0.0.1", "database ip")
	var metaPort = flag.String("dp", "3306", "database port")
	var user = flag.String("u", "root", "database user")
	var passwd = flag.String("pw", "", "database passwd")
	var db = flag.String("d", "speedy", "database name")
	var debug = flag.Bool("D", false, "log debug level")

	flag.Parse()

	api.InitAll(*metaHost, *metaPort, *user, *passwd, *db)

	//set log debug level
	if *debug {
		os.Setenv("DEBUG", "DEBUG")
	}

	err := api.LoadChunkserverInfo()
	if err != nil {
		log.Fatalf("loadChunkserverInfo error: %v", err)
	}

	go api.MonitorTicker(5, 30)

	router := initRouter()
	http.Handle("/", router)
	log.Infof("listen %s:%d", *serverHost, *serverPort)

	if err := http.ListenAndServe(*serverHost+":"+strconv.Itoa(*serverPort), nil); err != nil {
		log.Fatalf("listen error: %v", err)
	}
}