广告涉及的mq都放这里
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

54 line
1.0 KiB

  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "applet/app/cfg"
  8. "applet/app/db"
  9. "applet/app/task"
  10. "applet/app/utils"
  11. "applet/app/utils/logx"
  12. )
  13. func init() {
  14. // 加载任务配置
  15. cfg.InitTaskCfg()
  16. // 日志配置
  17. cfg.InitLog()
  18. // 初始化redis
  19. cfg.InitCache()
  20. baseDb := *cfg.DB
  21. baseDb.Path = fmt.Sprintf(cfg.DB.Path, cfg.DB.Name)
  22. if err := db.InitDB(&baseDb); err != nil {
  23. panic(err)
  24. }
  25. dataDb := *cfg.DataDB
  26. dataDb.Path = fmt.Sprintf(cfg.DataDB.Path, cfg.DataDB.Name)
  27. if err := db.InitDataDB(&dataDb); err != nil {
  28. panic(err)
  29. }
  30. imDb := *cfg.ImDB
  31. imDb.Path = fmt.Sprintf(cfg.ImDB.Path, cfg.ImDB.Name)
  32. if err := db.InitImDB(&imDb); err != nil {
  33. panic(err)
  34. }
  35. utils.CurlDebug = true
  36. //cfg.InitMemCache()
  37. }
  38. func main() {
  39. go func() {
  40. // 初始化jobs方法列表、添加reload方法定时更新任务
  41. task.Init()
  42. task.Run()
  43. }()
  44. // graceful shutdown
  45. quit := make(chan os.Signal)
  46. signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
  47. <-quit
  48. _ = logx.Info("Server exiting...")
  49. }