1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package config
- import (
- . "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/mail"
- "gopkg.in/natefinch/lumberjack.v2"
- )
- // OSSAccount 表示OSS帐号信息
- type OSSAccount struct {
- ID string `json:"id"`
- Endpoint string `json:"endpoint"`
- AccessKeyId string `json:"access_key_id"`
- AccessKeySecret string `json:"access_key_secret"`
- }
- // BucketInfo 表示bucket维表数据
- type BucketInfo struct {
- BucketID string `json:"bucket_id"`
- AccountID string `json:"account_id"`
- BucketName string `json:"bucket_name"`
- }
- type PushMail struct {
- Addr string `json:"addr"`
- Port int `json:"port"`
- Pwd string `json:"pwd"`
- User string `json:"user"`
- MailPoolSize int `json:"mailPoolSize"`
- MailReTry int `json:"mailReTry"`
- }
- // Config 为全局配置结构体
- type Config struct {
- Port string `json:"port"`
- OSSAccounts []OSSAccount `json:"oss_accounts"`
- Buckets []BucketInfo `json:"buckets"`
- Node struct {
- NodeName string `json:"node_name"`
- } `json:"node"`
- Redis struct {
- Address string `json:"address"`
- Password string `json:"password"`
- } `json:"redis"`
- Email struct {
- Mails []*PushMail `json:"mails"`
- Title string `json:"title"`
- Recipients []string `json:"recipients"`
- } `json:"email"`
- Weixin struct {
- WebhookURL string `json:"webhook_url"`
- } `json:"weixin"`
- WarnMaxNodeNum int `json:"warnMaxNodeNum"`
- WarnInterval int64 `json:"warnInterval"`
- Logger *lumberjack.Logger `json:"logger"`
- }
- var (
- AppConfig Config
- Gmails []*mail.GmailAuth
- )
- // LoadConfig 从指定的配置文件中加载配置
- func init() {
- ReadConfig(&AppConfig)
- Gmails = make([]*mail.GmailAuth, len(AppConfig.Email.Mails))
- for k, v := range AppConfig.Email.Mails {
- Gmails[k] = &mail.GmailAuth{
- SmtpHost: v.Addr,
- SmtpPort: v.Port,
- User: v.User,
- Pwd: v.Pwd,
- PoolSize: v.MailPoolSize,
- ReTry: v.MailReTry,
- }
- }
- }
|