package main

import (
	"WorldTester/conf"
	db "WorldTester/db"
	"common/logger"
	"flag"
	"time"
)

var (
	//	server_addr = "139.196.215.75:4321"
	server_addr     = "172.21.0.9:30054"
	do_trash        = false
	obeserver_count = 0
)

func InitLogger(file string, lvl int) {
	logger.New(file, lvl, logger.Rotate{Size: logger.GB, Expired: time.Hour * 24 * 7, Interval: time.Hour * 24})
}

func main() {
	conf_filepath := flag.String("conf_path", "./test.xml", "config file path")
	//logpath := flag.String("logpath", "./log", "config file log path")
	logpath := flag.String("logpath", "E:/PokerServer/src/WorldTester", "log file path")
	//roomcount := flag.Int("roomcount", 1, "total room count")
	//createinterval := flag.Int("interval", 1, "interval between room creating")
	lvl := flag.Int("lvl", 6, "log level")
	trash := flag.Int("trash", 0, "do crack test")
	observer := flag.Int("observer", 0, "do observer")
	flag.Parse()
	if *trash != 0 {
		do_trash = true
	}
	if *observer != 0 {
		obeserver_count = *observer
	}
	InitLogger(*logpath+"/tester.log", *lvl)
	conf.LoadConf(*conf_filepath)

	err := db.InitMysql()
	if err != nil {
		logger.Info("error init mysql error : %v", err)
		return
	}

	InitAllHost(1)
	HostLogin(1)

	//	if obeserver_count > 0 {
	//		StartObserver(*createinterval)
	//	}

	select {}
}
