Esempio n. 1
0
func main() {
	addr := config.Config.ListenAddress
	if !strings.Contains(addr, ":") {
		addr = fmt.Sprintf("%s:%d", addr, 1119)
	}

	if config.Config.Migrate {
		fmt.Printf("Performing database migration\n")
		pegasus.Migrate()
		return
	}

	debugListen := config.Config.DebugListenAddress
	if len(debugListen) != 0 {
		go func() {
			log.Printf("Debug http server listening on %s ...\n", debugListen)
			log.Println(http.ListenAndServe(debugListen, nil))
		}()
	}

	serv := bnet.NewServer()
	serv.RegisterGameServer("WTCG", pegasus.NewServer(serv))

	log.Printf("Listening on %s ...\n", addr)
	err := serv.ListenAndServe(addr)
	if err != nil {
		log.Println(err)
	}
}
Esempio n. 2
0
File: stove.go Progetto: thlac/stove
func main() {
	addr := fmt.Sprintf("%s:%d", CONN_DEFAULT_HOST, CONN_DEFAULT_PORT)
	flag.StringVar(&addr, "bind", addr, "The address to run on")
	runMigrate := flag.Bool("migrate", false, "Perform a database migration and exit")
	flag.Parse()

	if !strings.Contains(addr, ":") {
		addr = fmt.Sprintf("%s:%d", addr, CONN_DEFAULT_PORT)
	}

	if *runMigrate {
		fmt.Printf("Performing database migration\n")
		pegasus.Migrate()
		return
	}

	go func() {
		httpAddr := "localhost:6060"
		fmt.Printf("Debug http server listening on %s ...\n", httpAddr)
		fmt.Println(http.ListenAndServe(httpAddr, nil))
	}()

	serv := bnet.NewServer()
	serv.RegisterGameServer("WTCG", pegasus.NewServer(serv))

	fmt.Printf("Listening on %s ...\n", addr)
	err := serv.ListenAndServe(addr)
	if err != nil {
		fmt.Println(err)
	}
}