-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (38 loc) · 1.33 KB
/
main.go
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
//
// Copyright (c) 2021 朱俊杰
// All rights reserved
// filename: main.go
// description: 具体的main函数
// version: 0.1.0
// created by zhujunjie(1121883342@qq.com) at 2021-04-27
//
package main
import (
"context"
"github.com/InsideOfTheIndustry/TcpServe/config"
redisdatabase "github.com/InsideOfTheIndustry/TcpServe/database/redis"
"github.com/InsideOfTheIndustry/TcpServe/database/xormdatabase"
"github.com/InsideOfTheIndustry/TcpServe/logServer"
"github.com/InsideOfTheIndustry/TcpServe/server"
"github.com/InsideOfTheIndustry/TcpServe/utils/jwt"
)
func main() {
logServer.Setup("info") // 设置日志等级
config.Setup("./config/config.yaml") // 读取配置文件
jwt.InitSecretkey() // 初始化Scretkey
// 初始化xorm引擎
if err := xormdatabase.InitXormEngine(); err != nil {
logServer.Error("初始化xorm引擎失败: %s", err.Error())
}
redisdatabase.InitRedis() // 初始化reds
ctx, cancel := context.WithCancel(context.Background()) // 全局上下文控制
// ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
_, err := server.NewTcpServer(ctx) // 启动tcp服务
if err != nil {
logServer.Error("启动tcp服务失败:%s", err.Error())
return
}
<-ctx.Done()
logServer.Info("Tcp服务停止")
}