forked from tbghg/ByteDance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
44 lines (39 loc) · 798 Bytes
/
server.go
File metadata and controls
44 lines (39 loc) · 798 Bytes
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
package main
import (
"ByteDance/dal"
"ByteDance/pkg/middleware"
"ByteDance/utils"
"github.com/gin-gonic/gin"
"sync"
)
func main() {
wg := &sync.WaitGroup{}
wg.Add(3)
configInit(wg)
r := gin.Default()
// 启动redis
if dal.InitClient() {
r.Use(middleware.RateMiddleware)
}
initRouter(r) // 初始化路由
err := r.Run(":8000")
if err != nil {
wg.Wait()
utils.Log.Fatal("服务启动失败 " + err.Error())
}
}
func configInit(wg *sync.WaitGroup) {
utils.LogConfig() // 初始化日志配置
go func() {
utils.OSSInit() // OSS初始化,将ConnQuery与数据库绑定
wg.Done()
}()
go func() {
dal.MySQLInit() // MySQL初始化,连接数据库
wg.Done()
}()
go func() {
utils.SensitiveWordInit() // 读取敏感词,写入内存中
wg.Done()
}()
}