数据采集
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
789 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. // 初始化redis
  19. cfg.InitCache()
  20. cfg.InitEs() //ElasticSearch初始化
  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. }