conf.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package config
  2. import (
  3. "fmt"
  4. "github.com/BurntSushi/toml"
  5. "os"
  6. )
  7. var (
  8. // Conf crocodile conf
  9. Conf *conf
  10. )
  11. // Init Config
  12. func Init(conf string) {
  13. _, err := toml.DecodeFile(conf, &Conf)
  14. if err != nil {
  15. fmt.Printf("Err %v", err)
  16. os.Exit(1)
  17. }
  18. }
  19. type conf struct {
  20. Serve serve
  21. DB db
  22. Mail mail
  23. Log log
  24. }
  25. type serve struct {
  26. Udp string
  27. LoadStart int64
  28. Thread int
  29. SiteColl string
  30. ValidDays int
  31. StatusDays int
  32. BackupFlag bool
  33. }
  34. type node struct {
  35. Addr string
  36. Port int
  37. Memo string
  38. }
  39. type mail struct {
  40. Send bool
  41. To string
  42. Api string
  43. }
  44. // Log Config
  45. type log struct {
  46. LogPath string
  47. MaxSize int
  48. Compress bool
  49. MaxAge int
  50. MaxBackups int
  51. LogLevel string
  52. Format string
  53. }
  54. type db struct {
  55. Mongo mgo
  56. Mysql mysql
  57. Myck clickhouse
  58. Es es
  59. }
  60. type mgo struct {
  61. Addr string
  62. Dbname string
  63. Coll string
  64. Size int
  65. User string
  66. Password string
  67. }
  68. type mysql struct {
  69. Addr string
  70. Dbname string
  71. Size int
  72. User string
  73. Password string
  74. }
  75. type clickhouse struct {
  76. Addr string
  77. Dbname string
  78. User string
  79. Password string
  80. }
  81. type redis struct {
  82. Addr string
  83. AddrQb string
  84. DbQb int
  85. }
  86. type es struct {
  87. Addr string
  88. Size int
  89. Index string
  90. User string
  91. Password string
  92. }