conf.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. Pici int64
  30. SiteColl string
  31. ValidDays int
  32. StatusDays int
  33. BackupFlag bool
  34. }
  35. type node struct {
  36. Addr string
  37. Port int
  38. Memo string
  39. }
  40. type mail struct {
  41. Send bool
  42. To string
  43. Api string
  44. }
  45. // Log Config
  46. type log struct {
  47. LogPath string
  48. MaxSize int
  49. Compress bool
  50. MaxAge int
  51. MaxBackups int
  52. LogLevel string
  53. Format string
  54. }
  55. type db struct {
  56. Mongo mgo
  57. Mysql mysql
  58. Myck clickhouse
  59. Es es
  60. Projectes es
  61. }
  62. type mgo struct {
  63. Addr string
  64. Dbname string
  65. Coll string
  66. Size int
  67. User string
  68. Password string
  69. }
  70. type mysql struct {
  71. Addr string
  72. Dbname string
  73. Size int
  74. User string
  75. Password string
  76. }
  77. type clickhouse struct {
  78. Addr string
  79. Dbname string
  80. User string
  81. Password string
  82. }
  83. type redis struct {
  84. Addr string
  85. AddrQb string
  86. DbQb int
  87. }
  88. type es struct {
  89. Addr string
  90. Size int
  91. Index string
  92. User string
  93. Password string
  94. }