package main

import (
	_ "jy/admin"
	_ "jy/admin/audit"
	_ "jy/admin/distribution"
	_ "jy/admin/task"
	"jy/extract"
	_ "jy/front"
	. "jy/router"
	"jy/util"
	qu "qfw/util"
	//"qfw/util/elastic"
	redis "qfw/util/redis"

	log "github.com/donnie4w/go-logger/logger"
)

func init() {
	log.SetConsole(false)
	log.SetLevel(log.DEBUG)
	log.SetRollingDaily("./", "out.log")
	qu.ReadConfig(&util.Config)
	qu.ReadConfig("./res/brandrule.json", &util.BrandRules)
	qu.ReadConfig("./res/goods.json", &util.GoodsConfig)
	qu.ReadConfig("./res/brand.json", &util.BrandConfig)
	//初始化品牌和商品
	util.InitBrand()
	util.InitGoods()
	//初始化mongo连接
	util.InitMgoPool()
	//初始化redis
	redis.InitRedisBySize(qu.ObjToString(util.Config["redis"]), 50, 30, 240)
	//初始化elastic连接
	//"winner=172.17.145.179:2710,buyer=172.17.145.179:2711"
	//elastic.InitElasticSize(qu.ObjToString(util.Config["elasticsearch"]), qu.IntAllDef(util.Config["elasticPoolSize"], 30))
}

func main() {
	extract.ExtractUdp() //udp通知抽取
	extract.ClearUdp()   //udp通知清理
	go extract.Export()
	go Router.Run(":" + qu.ObjToString(util.Config["port"]))
	go log.Debug("启动..", qu.ObjToString(util.Config["port"]))
	lock := make(chan bool)
	<-lock
}
