Ejemplo n.º 1
0
func main() {
	glog.Info("Web Server:Loading...")
	b := flag.Bool("benchmark", false, "")
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Parse()
	if *b {
		glog.Info("Benchmark Mode")
		// Creat a file
		f, err := os.Create("pprof")
		if err != nil {
			glog.Fatal(err)
		}
		if err = pprof.StartCPUProfile(f); err != nil {
			glog.Fatal(err)
		}
		defer pprof.StopCPUProfile()
	}
	defer glog.Flush()

	glog.Info("Read the config.")
	if err := InitConf(); err != nil {
		glog.Fatal(err)
	}

	glog.Info("[Web]: listener start.")
	go start()

	signal.HandleSignal(signal.InitSignal())
}
Ejemplo n.º 2
0
func main() {
	glog.Info("Comet Server:Loading...")
	b := flag.Bool("benchmark", false, "")
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Parse()
	if *b {
		glog.Info("Benchmark Mode")
		// Creat a file
		f, err := os.Create("pprof")
		if err != nil {
			glog.Fatal(err)
		}
		if err = pprof.StartCPUProfile(f); err != nil {
			glog.Fatal(err)
		}
		defer pprof.StopCPUProfile()
	}
	defer glog.Flush()

	glog.Info("Read the config.")
	if err := InitConf(); err != nil {
		glog.Fatal(err)
	}

	// Open the RPC listener.
	glog.Infof("Comet RPC Listen at:%v", Conf.RPC_addr)
	go listenRPC()
	// Open the cliens's server
	glog.Infof("Comet listen at: %v", Conf.Listen_addr)
	go startListen(CLIENT, Conf.Listen_addr)

	signal.HandleSignal(signal.InitSignal())
	glog.Info("System exit.")
}