示例#1
0
func main() {
	defer func() {
		cleanup()

		if err := recover(); err != nil {
			fmt.Println(err)
			debug.PrintStack()
		}
	}()

	go server.RunSysStats(time.Now(), time.Duration(options.tick)*time.Second)

	gcollector := NewGcollector(GcollectorConf)
	gcollector.RunForever()
}
示例#2
0
文件: main.go 项目: cmotc/pushd
func main() {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
			debug.PrintStack()
		}
		shutdown()
	}()

	pushdServer = server.NewTcpServer("pushd")
	go server.RunSysStats(time.Now(), time.Duration(options.tick)*time.Second)

	servStats := engine.NewServerStats()
	pushdClientProcessor := engine.NewPushdClientProcessor(pushdServer, servStats)
	if !options.aclCheck {
		pushdClientProcessor.DisableAclCheck()
	}
	go pushdServer.LaunchTcpServer(config.PushdConf.TcpListenAddr, pushdClientProcessor, config.PushdConf.SessionTimeout, config.PushdConf.ServInitialGoroutineNum)
	go servStats.Start(config.PushdConf.StatsOutputInterval, config.PushdConf.MetricsLogfile)

	if config.PushdConf.LongPollingListenAddr != "" {
		longPollingServer := engine.NewPushdLongPollingServer("pushd(long polling)")
		go longPollingServer.Launch(config.PushdConf.LongPollingListenAddr, config.PushdConf.LongPollingSessionTimeout)
	}

	if config.PushdConf.IsDistMode() {
		s2sServer = server.NewTcpServer("pushd_s2s")
		go s2sServer.LaunchTcpServer(config.PushdConf.S2sListenAddr, engine.NewS2sClientProcessor(s2sServer), config.PushdConf.S2sSessionTimeout, config.PushdConf.S2sIntialGoroutineNum)

		err := engine.RegisterEtc()
		if err != nil {
			panic(err)
		}

		engine.Proxy = engine.NewS2sProxy()
		go engine.Proxy.WaitMsg()
	}

	if config.PushdConf.EnableStorage() {
		storage.Init()
		go storage.Serv()
	}

	<-make(chan int)
}