package main

import (
	qu "qfw/util"
	"time"

	"./front"
	"./logic"
	"./microservice"
	"./task"
	. "./util"

	"github.com/go-xweb/xweb"
)

func init() {
	qu.ReadConfig(&Sysconfig) //初始化配置
	InitMgoPool()             //初始化连接

	//xweb框架配置
	xweb.Config.RecoverPanic = true
	xweb.Config.Profiler = true
	xweb.RootApp().AppConfig.TemplateDir = "web/templates"
	xweb.RootApp().AppConfig.StaticDir = "web/res"
	xweb.RootApp().AppConfig.StaticFileVersion = false
	xweb.RootApp().AppConfig.CheckXsrf = false
	xweb.RootApp().AppConfig.ReloadTemplates = true
	xweb.RootApp().AppConfig.EnableHttpCache = false
	xweb.RootApp().AppConfig.Mode = xweb.Product
	xweb.RootApp().AppConfig.CacheTemplates = false
	xweb.AddAction(&front.Front{})
	xweb.AddAction(&task.Task{})
	xweb.AddAction(&logic.Logic{})
	xweb.AddAction(&microservice.Service{})
	xweb.RootApp().AppConfig.SessionTimeout = 1 * time.Hour
	xweb.RootApp().Logger.SetOutputLevel(4)
	//xweb.AddTmplVar("add", func(a, b int) int { return a + b })
}

func main() {
	xweb.Run(":" + qu.ObjToString(Sysconfig["port"]))
}
