附近小店
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.
 
 
 

45 line
749 B

  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/logx"
  11. )
  12. func init() {
  13. cfg.InitTaskCfg()
  14. cfg.InitLog()
  15. cfg.InitCache()
  16. cfg.InitCacheSecond()
  17. cfg.InitEs() //ElasticSearch初始化
  18. cfg.InitMq()
  19. baseDb := *cfg.DB
  20. baseDb.Path = fmt.Sprintf(cfg.DB.Path, cfg.DB.Name)
  21. if err := db.InitDB(&baseDb); err != nil {
  22. panic(err)
  23. }
  24. if err := db.InitZhimengDB(cfg.ZhimengDB); err != nil {
  25. panic(err)
  26. }
  27. //utils.CurlDebug = true
  28. cfg.InitMemCache()
  29. }
  30. func main() {
  31. go func() {
  32. task.Init()
  33. task.Run()
  34. }()
  35. // graceful shutdown
  36. quit := make(chan os.Signal)
  37. signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
  38. <-quit
  39. _ = logx.Info("Server exiting...")
  40. }