init.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package main
  2. import (
  3. "fmt"
  4. "jygit.jydev.jianyu360.cn/data_processing/common_utils/elastic"
  5. "jygit.jydev.jianyu360.cn/data_processing/common_utils/log"
  6. "jygit.jydev.jianyu360.cn/data_processing/common_utils/mysqldb"
  7. "os"
  8. "timedtasks/config"
  9. )
  10. var (
  11. Es *elastic.Elastic
  12. MysqlTool *mysqldb.Mysql
  13. )
  14. // InitLog @Description
  15. // @Author J 2022/7/26 15:30
  16. func InitLog() {
  17. logcfg := config.Conf.Log
  18. err := log.InitLog(
  19. log.Path(logcfg.LogPath),
  20. log.Level(logcfg.LogLevel),
  21. log.Compress(logcfg.Compress),
  22. log.MaxSize(logcfg.MaxSize),
  23. log.MaxBackups(logcfg.MaxBackups),
  24. log.MaxAge(logcfg.MaxAge),
  25. log.Format(logcfg.Format),
  26. )
  27. if err != nil {
  28. fmt.Printf("InitLog failed: %v\n", err)
  29. os.Exit(1)
  30. }
  31. }
  32. func InitMysql() {
  33. dbcfg := config.Conf.Mysql
  34. MysqlTool = &mysqldb.Mysql{
  35. Address: dbcfg.Addr,
  36. DBName: dbcfg.Dbname,
  37. UserName: dbcfg.User,
  38. PassWord: dbcfg.Password,
  39. }
  40. MysqlTool.Init()
  41. }
  42. func initEs() {
  43. escfg := config.Conf.Es
  44. Es = &elastic.Elastic{
  45. S_esurl: escfg.Addr,
  46. I_size: escfg.Size,
  47. Username: escfg.Username,
  48. Password: escfg.Password,
  49. }
  50. Es.InitElasticSize()
  51. }