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/FishChatServer/monitor/views") beego.SetStaticPath("/views", "views") beego.Run() }
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) { }) }
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) }) }
func main() { version() fmt.Printf("built on %s\n", BuildTime()) flag.Parse() cfg := NewManagerConfig(*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()) } log.Info("server start:", server.Listener().Addr().String()) sm := NewManager(cfg) go sm.subscribeChannels() server.Serve(func(session *libnet.Session) { }) }