Ejemplo n.º 1
0
func main() {
	version()
	fmt.Printf("built on %s\n", BuildTime())
	flag.Parse()
	cfg := NewMonitorConfig(*InputConfFile)
	err := cfg.LoadConfig()
	if err != nil {
		log.Error(err.Error())
		return
	}

	server, err := libnet.Listen(cfg.TransportProtocols, cfg.Listen)
	if err != nil {
		log.Error(err.Error())
		return
	}
	log.Info("server start: ", server.Listener().Addr().String())

	m := NewMonitor(cfg)
	//TODO not use go
	m.subscribeChannels()
	go server.Serve(func(session *libnet.Session) {

	})

	beego.Router("api/v1/monitor", &controllers.MonitorController{})
	//beego.SetStaticPath("/views", "/mh/mygo/src/github.com/oikomi/FishChatServer/monitor/views")
	beego.SetStaticPath("/views", "views")
	beego.Run()
}
Ejemplo n.º 2
0
func main() {
	version()
	fmt.Printf("built on %s\n", BuildTime())
	flag.Parse()
	cfg := NewGatewayConfig(*InputConfFile)
	err := cfg.LoadConfig()
	if err != nil {
		glog.Error(err.Error())
		return
	}

	gw := NewGateway(cfg)

	gw.server, err = libnet.Listen(cfg.TransportProtocols, cfg.Listen)
	if err != nil {
		glog.Error(err.Error())
		return
	}
	glog.Info("gateway server running at ", gw.server.Listener().Addr().String())

	gw.server.Serve(func(session *libnet.Session) {
		glog.Info("client ", session.Conn().RemoteAddr().String(), " | come in")

		go handleSession(gw, session)
	})
}
Ejemplo n.º 3
0
func main() {
	version()
	fmt.Printf("built on %s\n", BuildTime())
	flag.Parse()
	cfg := NewRouterConfig(*InputConfFile)
	err := cfg.LoadConfig()
	if err != nil {
		glog.Error(err.Error())
		return
	}

	server, err := libnet.Listen(cfg.TransportProtocols, cfg.Listen)
	if err != nil {
		glog.Error(err.Error())
		return
	}
	glog.Info("server start: ", server.Listener().Addr().String())

	r := NewRouter(cfg)
	//TODO not use go
	go r.subscribeChannels()
	server.Serve(func(session *libnet.Session) {

	})
}
Ejemplo n.º 4
0
func main() {
	version()
	fmt.Printf("built on %s\n", BuildTime())
	flag.Parse()
	cfg := NewRouterConfig(*InputConfFile)
	err := cfg.LoadConfig()
	if err != nil {
		log.Error(err.Error())
		return
	}

	server, err := libnet.Listen(cfg.TransportProtocols, cfg.Listen)
	if err != nil {
		log.Error(err.Error())
		return
	}
	log.Info("server start: ", server.Listener().Addr().String())

	rs := redis_store.NewRedisStore(&redis_store.RedisStoreOptions{
		Network:        "tcp",
		Address:        cfg.Redis.Addr + cfg.Redis.Port,
		ConnectTimeout: time.Duration(cfg.Redis.ConnectTimeout) * time.Millisecond,
		ReadTimeout:    time.Duration(cfg.Redis.ReadTimeout) * time.Millisecond,
		WriteTimeout:   time.Duration(cfg.Redis.WriteTimeout) * time.Millisecond,
		Database:       1,
		KeyPrefix:      base.COMM_PREFIX,
	})
	r := NewRouter(cfg, rs)
	//TODO not use go
	go r.subscribeChannels()
	server.Serve(func(session *libnet.Session) {

	})
}
Ejemplo n.º 5
0
func main() {
	version()
	fmt.Printf("built on %s\n", BuildTime())
	flag.Parse()
	cfg := NewMsgServerConfig(*InputConfFile)
	err := cfg.LoadConfig()
	if err != nil {
		log.Error(err.Error())
		return
	}

	rs := redis_store.NewRedisStore(&redis_store.RedisStoreOptions{
		Network:        "tcp",
		Address:        cfg.Redis.Addr + cfg.Redis.Port,
		ConnectTimeout: time.Duration(cfg.Redis.ConnectTimeout) * time.Millisecond,
		ReadTimeout:    time.Duration(cfg.Redis.ReadTimeout) * time.Millisecond,
		WriteTimeout:   time.Duration(cfg.Redis.WriteTimeout) * time.Millisecond,
		Database:       1,
		KeyPrefix:      base.COMM_PREFIX,
	})

	ms := NewMsgServer(cfg, rs)

	ms.server, err = libnet.Listen(cfg.TransportProtocols, cfg.Listen)
	if err != nil {
		panic(err)
	}
	log.Info("msg_server running at  ", ms.server.Listener().Addr().String())

	ms.createChannels()

	go ms.scanDeadSession()

	go ms.sendMonitorData()

	ms.server.Serve(func(session *libnet.Session) {
		log.Info("a new client ", session.Conn().RemoteAddr().String(), " | come in")
		go handleSession(ms, session)
	})
}