main.go
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"ability/controllers"
"ability/protocol"
_ "ability/routers"
"github.com/astaxie/beego"
_ "github.com/go-sql-driver/mysql"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/config"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/redis"
"time"
)
func init() {
time.Local = time.FixedZone("CST", 3600*8)
log.InitLog(config.Logger{
Filename: "app.log",
Level: "7",
})
//TODO:kafka配置
log.InitKafkaLogger(log.KafkaConfig{
Topic: "ability",
Addrs: []string{"127.0.0.1:9092"},
Level: 6,
})
err := redis.InitWithDb(100, beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"), "0")
if err != nil {
log.Fatal(err)
panic(err)
}
orm.NewBeeormEngine(config.Mysql{
DataSource: beego.AppConfig.String("data_source"),
MaxIdle: 100,
MaxOpen: 100,
})
//TODO:邮件服务配置
common.InitMailService(&common.MailConfig{
//Host:"smtp.qq.com",
//Port:465,
//From:"785410885@qq.com",
//Password:"ibfduqhfmgypbffe", //授权码
//IsUseSsl:true,
})
}
func main() {
defer func() {
log.Info("app on stop!")
}()
beego.InsertFilter("/*", beego.BeforeRouter, controllers.FilterComm)
protocol.InitMessageCode()
log.Info("app on start!")
log.Info("Beego Run Mode:", beego.BConfig.RunMode)
beego.Run()
}