main.go 1.4 KB

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