蛋蛋星球RabbitMq消费项目
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.
 
 
 
 
 
 

51 lines
892 B

  1. package main
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/db"
  5. "applet/app/utils"
  6. "applet/app/utils/logx"
  7. "applet/consume"
  8. "fmt"
  9. "os"
  10. "os/signal"
  11. "syscall"
  12. )
  13. // 系统初始化
  14. func init() {
  15. cfg.InitCfg() //配置初始化
  16. cfg.InitLog() //日志初始化
  17. cfg.InitCache() //缓存初始化
  18. cfg.InitMq() //队列初始化
  19. cfg.InitEs() //ElasticSearch初始化
  20. if cfg.Debug { //判断是否是debug
  21. if err := db.InitDB(cfg.DB); err != nil { //主数据库初始化
  22. panic(err)
  23. }
  24. if err := db.InitImDB(cfg.IMDB); err != nil { // IM主数据库初始化
  25. panic(err)
  26. }
  27. }
  28. fmt.Println("init success")
  29. }
  30. func main() {
  31. if cfg.CurlDebug {
  32. utils.CurlDebug = true
  33. }
  34. go func() {
  35. // 初始化
  36. consume.Init()
  37. consume.Run()
  38. }()
  39. quit := make(chan os.Signal)
  40. signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
  41. <-quit
  42. _ = logx.Info("Server exiting...")
  43. }