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

2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  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.InitMq()
  17. baseDb := *cfg.DB
  18. baseDb.Path = fmt.Sprintf(cfg.DB.Path, cfg.DB.Name)
  19. if err := db.InitDB(&baseDb); err != nil {
  20. panic(err)
  21. }
  22. if err := db.InitZhimengDB(cfg.ZhimengDB); err != nil {
  23. panic(err)
  24. }
  25. //utils.CurlDebug = true
  26. cfg.InitMemCache()
  27. }
  28. func main() {
  29. go func() {
  30. task.Init()
  31. task.Run()
  32. }()
  33. // graceful shutdown
  34. quit := make(chan os.Signal)
  35. signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
  36. <-quit
  37. _ = logx.Info("Server exiting...")
  38. }