package main

import (
	log "github.com/donnie4w/go-logger/logger"
	"gopkg.in/mgo.v2/bson"
	_ "jy/admin"
	_ "jy/admin/audit"
	_ "jy/admin/distribution"
	_ "jy/admin/task"
	"jy/extract"
	_ "jy/front"
	. "jy/router"
	u "jy/util"
	"net/http"
	_ "net/http/pprof"
	qu "qfw/util"
)

func init() {
	log.SetConsole(false)
	log.SetLevel(log.DEBUG)
	log.SetRollingDaily("./", "out.log")
	qu.ReadConfig(&u.Config)
	qu.ReadConfig("./res/regions.json", &u.RegionsConfig)
	//抽取price和number相关
	qu.ReadConfig("./res/pricenumber.json", &u.PriceNumberConfig)
	//初始化util
	u.UtilInit()
}
func main() {
	extract.ExtractUdpUpdateMachine()  //节点上传~构建
	extract.ExtractUdp()               //udp通知抽取
	go extract.GetExtractUdpTaskInfo() //抽取任务获取
	go Router.Run(":" + qu.ObjToString(u.Config["port"]))
	go log.Debug("启动..", qu.ObjToString(u.Config["port"]))
	go func() {
		http.ListenAndServe("localhost:10000", nil)
	}()
	lock := make(chan bool)
	<-lock
}

// 验证规则
func testMain() {
	con := `2134576`
	text := con[1:2]
	log.Debug(text)
}

func testPostDfa() {
	text := "正文描述广州城市职业学院正文描述"
	dfa_info := extract.EmployPostEntDfa(bson.M{"detail": text})
	log.Debug(dfa_info)
}
