蛋蛋星球-客户端
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 lines
782 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"
  11. "applet/app/utils/logx"
  12. )
  13. func init() {
  14. // 加载任务配置
  15. cfg.InitTaskCfg()
  16. // 日志配置
  17. cfg.InitLog()
  18. cfg.InitMq() // 队列初始化
  19. // 初始化redis
  20. cfg.InitCache()
  21. baseDb := *cfg.DB
  22. baseDb.Path = fmt.Sprintf(cfg.DB.Path, cfg.DB.Name)
  23. if err := db.InitDB(&baseDb); err != nil {
  24. panic(err)
  25. }
  26. utils.CurlDebug = true
  27. //cfg.InitMemCache()
  28. }
  29. func main() {
  30. go func() {
  31. // 初始化jobs方法列表、添加reload方法定时更新任务
  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. }