蛋蛋星球 后台端
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.

main.go 895 B

2 months ago
1 month ago
2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. baseImDb := *cfg.IMDB
  26. baseImDb.Path = fmt.Sprintf(cfg.IMDB.Path, cfg.IMDB.Name)
  27. if err := db.InitImDB(&baseImDb); err != nil {
  28. panic(err)
  29. }
  30. utils.CurlDebug = true
  31. //cfg.InitMemCache()
  32. }
  33. func main() {
  34. go func() {
  35. // 初始化jobs方法列表、添加reload方法定时更新任务
  36. task.Init()
  37. task.Run()
  38. }()
  39. // graceful shutdown
  40. quit := make(chan os.Signal)
  41. signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
  42. <-quit
  43. _ = logx.Info("Server exiting...")
  44. }