main.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // main
  2. package main
  3. import (
  4. "crypto/md5"
  5. "encoding/hex"
  6. "front"
  7. "log"
  8. qu "qfw/util"
  9. "strings"
  10. "util"
  11. "github.com/go-xweb/xweb"
  12. )
  13. func MD5(appid, t, secret string) string {
  14. h := md5.New()
  15. h.Write([]byte(appid + t + secret))
  16. return strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
  17. }
  18. func init() {
  19. //log.Println(MD5("jynw166_fEs2021", "1617340065", "Tgb#8diO90L"))
  20. //os.Exit(0)
  21. qu.ReadConfig(&util.Config)
  22. util.InitConfig()
  23. //util.InitInfluxdb(util.Config.InfluxdbUrl)
  24. //redis
  25. //redis.InitRedis(util.Config.Redis)
  26. //oss
  27. util.InitOss()
  28. //xweb框架配置
  29. xweb.Config.RecoverPanic = true
  30. xweb.Config.Profiler = true
  31. xweb.RootApp().AppConfig.TemplateDir = "web/templates"
  32. xweb.RootApp().AppConfig.StaticDir = "web/staticres"
  33. xweb.RootApp().AppConfig.StaticFileVersion = false
  34. xweb.RootApp().AppConfig.CheckXsrf = false
  35. xweb.RootApp().AppConfig.ReloadTemplates = false
  36. xweb.RootApp().AppConfig.EnableHttpCache = false
  37. xweb.RootApp().AppConfig.Mode = xweb.Product
  38. xweb.RootApp().AppConfig.CacheTemplates = false
  39. xweb.AddAction(&front.Front{})
  40. //_id初始化内存
  41. log.Println("_id初始化内存...")
  42. //front.IdList = list.New()
  43. //加载所有数据,存入IdList
  44. //ls, _ := util.MgoM.Find(util.Config.Fromtable, `{"check":{"$exists":0}}`, nil, `{"_id":1}`, false, -1, -1)
  45. //ls, _ := util.MgoM.Find(util.Coll, nil, nil, `{"_id":1}`, false, -1, -1)
  46. //for _, v := range *ls {
  47. // front.IdList.PushBack(mgo.BsonIdToSId(v["_id"]))
  48. //}
  49. //qu.Debug("_id初始化内存完成", front.IdList.Len())
  50. // front.IdPackList = list.New()
  51. // //加载所有未标注数据且含有分包信息的数据
  52. // lspack, _ := util.MgoM.Find(util.Config.Fromtable, `{"check":{"$exists":0},"package":{"$exists":1}}`, nil, `{"_id":1}`, false, -1, -1)
  53. // for _, v := range *lspack {
  54. // front.IdPackList.PushBack(mgo.BsonIdToSId(v["_id"]))
  55. // }
  56. // log.Println("_id初始化内存完成_分包", front.IdPackList.Len())
  57. }
  58. func main() {
  59. xweb.Run(":" + util.Config.Port)
  60. }