golang 的 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.
 
 
 

53 regels
995 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.InitDataDB(cfg.DataDB); err != nil { //数据大屏本身库初始化
  25. panic(err)
  26. }
  27. channel := make(chan int, 0) //开辟管道,缓冲为
  28. go db.InitDBs(channel)
  29. <-channel
  30. }
  31. fmt.Println("init success")
  32. }
  33. func main() {
  34. if cfg.CurlDebug {
  35. utils.CurlDebug = true
  36. }
  37. go func() {
  38. // 初始化
  39. consume.Init()
  40. consume.Run()
  41. }()
  42. quit := make(chan os.Signal)
  43. signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
  44. <-quit
  45. _ = logx.Info("Server exiting...")
  46. }