conf.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. Nsq nsq
  23. UdpNode []node
  24. Mail mail
  25. Log log
  26. }
  27. type serve struct {
  28. Udp string
  29. LoadStart int64
  30. Thread int
  31. SiteColl string
  32. ValidDays int
  33. StatusDays int
  34. BackupFlag bool
  35. }
  36. type node struct {
  37. Addr string
  38. Port int
  39. Memo string
  40. }
  41. type mail struct {
  42. Send bool
  43. To string
  44. Api string
  45. }
  46. // Log Config
  47. type log struct {
  48. LogPath string
  49. MaxSize int
  50. Compress bool
  51. MaxAge int
  52. MaxBackups int
  53. LogLevel string
  54. Format string
  55. }
  56. type db struct {
  57. MongoP mgo
  58. MongoB mgo
  59. MongoS mgo
  60. Es es
  61. Redis redis
  62. }
  63. type mgo struct {
  64. Addr string
  65. Dbname string
  66. Coll string
  67. Size int
  68. User string
  69. Password string
  70. }
  71. type nsq struct {
  72. Addr string
  73. Topic string
  74. Channel string
  75. Concurrent int
  76. }
  77. type redis struct {
  78. Addr string
  79. AddrQb string
  80. DbQb int
  81. }
  82. type es struct {
  83. Addr string
  84. Size int
  85. Index string
  86. User string
  87. Password string
  88. }