main.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package main
  2. import (
  3. util "common_utils"
  4. "crons"
  5. _ "filter"
  6. "front"
  7. "github.com/cron"
  8. qu "qfw/util"
  9. "time"
  10. . "util"
  11. "github.com/go-xweb/xweb"
  12. )
  13. func init() {
  14. qu.ReadConfig(&Sysconfig) //初始化config
  15. qu.ReadConfig("./web/qua_res/qua_config.json", &Quaconfig)
  16. InitConfig() //初始化连接
  17. InitOss()
  18. //xweb框架配置
  19. xweb.Config.RecoverPanic = true
  20. xweb.Config.Profiler = true
  21. xweb.RootApp().AppConfig.TemplateDir = "web/templates"
  22. xweb.RootApp().AppConfig.StaticDir = "web/res"
  23. xweb.RootApp().AppConfig.StaticFileVersion = false
  24. xweb.RootApp().AppConfig.CheckXsrf = false
  25. xweb.RootApp().AppConfig.ReloadTemplates = true
  26. xweb.RootApp().AppConfig.EnableHttpCache = false
  27. xweb.RootApp().AppConfig.Mode = xweb.Product
  28. xweb.RootApp().AppConfig.CacheTemplates = false
  29. xweb.AddAction(&front.Front{})
  30. xweb.RootApp().AppConfig.SessionTimeout = 1 * time.Hour
  31. xweb.RootApp().Logger.SetOutputLevel(4)
  32. //xweb.AddTmplVar("add", func(a, b int) int { return a + b })
  33. }
  34. func cronTask() {
  35. defer util.Catch()
  36. c := cron.New()
  37. biddingHConf := Sysconfig["high_mark"].(map[string]interface{})
  38. if biddingHConf["spec"] == nil || biddingHConf["spec"] == "" {
  39. util.Debug("高质量库 定时任务 为空,请配置")
  40. } else {
  41. err := c.AddFunc(biddingHConf["spec"].(string), crons.MarkTask)
  42. if err != nil {
  43. util.Debug("cronTask err", err)
  44. }
  45. c.Start()
  46. defer c.Stop()
  47. select {}
  48. }
  49. }
  50. func main() {
  51. go cronTask()
  52. xweb.Run(":" + qu.ObjToString(Sysconfig["port"]))
  53. }