コード例 #1
0
ファイル: warserver.go プロジェクト: Tactique/proxy
func Main() {
	porterIPString := flag.String("porterIP", "127.0.0.1", "Porter Server IP")
	porterPortString := flag.String("porterPort", ":5269", "Porter Server Port")
	portstring := flag.String("port", ":8888", "Server port")
	tcpportstring := flag.String("tcpport", ":11199", "TCP socket port")
	logpath := flag.String("logpath", "/dev/stderr", "Logging location")
	flag.Parse()

	port = PortMgmt.NewPortInfo(*portstring)
	tcpPort = PortMgmt.NewPortInfo(*tcpportstring)
	porterPort = PortMgmt.NewPortInfo(*porterPortString)
	porterIP = PortMgmt.IPString(*porterIPString)

	logger.SetupLoggerHelper(*logpath)

	if !verifyEnvironment() {
		logger.Fatalf("Please set $ROOTIQUE to your project root")
	}
	setupGamehub()

	go gamehub.handleConnections()

	go socketListen(tcpPort.Port)
	logger.Debugf("Socket listening on port %s", tcpPort)

	http.HandleFunc("/ws", serveWs)

	logger.Debugf("Http server listening on port %s", port)
	err := http.ListenAndServe(port.Port, nil)
	if err != nil {
		logger.Fatalf("ListenAndServe: %s", err.Error())
	}
}
コード例 #2
0
ファイル: engine.go プロジェクト: Tactique/game_engine
func Main() {
	var port = flag.Int("port", 5269, "path to write the generated json")
	var write_template = flag.Bool("write_templates", false, "whether to write the template response json")
	var template_out_dir = flag.String("template_out_dir", ".", "path to write the generated template json")
	var logpath = flag.String("logpath", "/dev/stdout", "Logging location")
	flag.Parse()

	logger.SetupLoggerHelper(*logpath)

	if *write_template {
		generateTemplates(*template_out_dir)
		os.Exit(0)
	} else {
		logger.Infof("Starting Tactique on port %d!", *port)
		panic(listenForever(*port))
	}
}