广告平台(站长下代理使用)
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 776 B

3 months ago
2 months ago
3 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package main
  2. import (
  3. db "code.fnuoos.com/zhimeng/model.git/src"
  4. "fmt"
  5. "os"
  6. "os/signal"
  7. "syscall"
  8. "applet/app/cfg"
  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. utils.CurlDebug = true
  26. //cfg.InitMemCache()
  27. }
  28. func main() {
  29. go func() {
  30. // 初始化jobs方法列表、添加reload方法定时更新任务
  31. task.Init()
  32. task.Run()
  33. }()
  34. // graceful shutdown
  35. quit := make(chan os.Signal)
  36. signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
  37. <-quit
  38. _ = logx.Info("Server exiting...")
  39. }