12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package main
- import (
- util "common_utils"
- "crons"
- _ "filter"
- "front"
- "github.com/cron"
- qu "qfw/util"
- "time"
- . "util"
- "github.com/go-xweb/xweb"
- )
- func init() {
- qu.ReadConfig(&Sysconfig) //初始化config
- qu.ReadConfig("./web/qua_res/qua_config.json", &Quaconfig)
- InitConfig() //初始化连接
- InitOss()
- //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.RootApp().AppConfig.SessionTimeout = 1 * time.Hour
- xweb.RootApp().Logger.SetOutputLevel(4)
- //xweb.AddTmplVar("add", func(a, b int) int { return a + b })
- }
- func cronTask() {
- defer util.Catch()
- c := cron.New()
- biddingHConf := Sysconfig["high_mark"].(map[string]interface{})
- if biddingHConf["spec"] == nil || biddingHConf["spec"] == "" {
- util.Debug("高质量库 定时任务 为空,请配置")
- } else {
- err := c.AddFunc(biddingHConf["spec"].(string), crons.MarkTask)
- if err != nil {
- util.Debug("cronTask err", err)
- }
- c.Start()
- defer c.Stop()
- select {}
- }
- }
- func main() {
- go cronTask()
- xweb.Run(":" + qu.ObjToString(Sysconfig["port"]))
- }
|