conf.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. }
  61. type mgo struct {
  62. Addr string
  63. Dbname string
  64. Coll string
  65. Size int
  66. User string
  67. Password string
  68. }
  69. type mysql struct {
  70. Addr string
  71. Dbname string
  72. Size int
  73. User string
  74. Password string
  75. }
  76. type clickhouse struct {
  77. Addr string
  78. Dbname string
  79. User string
  80. Password string
  81. }
  82. type redis struct {
  83. Addr string
  84. AddrQb string
  85. DbQb int
  86. }
  87. type es struct {
  88. Addr string
  89. Size int
  90. Index string
  91. User string
  92. Password string
  93. }