Пример #1
0
func main() {
	foreGround := flag.Bool("foreground", true, "run as foreground")
	configFile := flag.String("config", "config.toml", "the config file")

	flag.Parse()

	//	f, _ := os.Create("profiler")
	//	pprof.StartCPUProfile(f)
	//	defer func() {
	//		pprof.StopCPUProfile()
	//		os.Exit(0)
	//	}()

	if !*foreGround {
		err := util.Daemonize(0, 0)
		if err != 0 {
			log.Info("daemonize failed")
			os.Exit(-1)
		}
	}

	pid := os.Getpid()
	log.Info("Server pid: %d started", pid)

	confpath, _ := filepath.Abs(*configFile)
	runtime.GOMAXPROCS(runtime.NumCPU())
	app := server.NewApplication(confpath)
	app.Start()
	app.Loop()

	log.Info("Server pid: %d finished", pid)
}
Пример #2
0
func startMq(configFile string) {
	pid := os.Getpid()
	log.Info("Server pid: ", pid)

	confpath, _ := filepath.Abs(configFile)
	app := server.NewApplication(confpath)

	//fmt.Println(app)
	//app.On("connect")

	app.Start()
	app.Loop()
}