-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (51 loc) · 1.28 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
_ "fmt"
_ "net/http"
"panel_backend/core"
"panel_backend/global"
"panel_backend/routers"
_ "panel_backend/utils/jwts"
_ "time"
"panel_backend/tests"
_ "github.com/gin-gonic/gin"
_ "github.com/golang-jwt/jwt/v5"
_ "github.com/sirupsen/logrus"
_"panel_backend/models"
)
func main() {
// 初始化自定义日志
global.Log = core.InitLogger("Log_panel/", "panel")
// 初始化配置项
global.Config = core.InitConfig()
// 初始化数据库
global.DB = core.InitMysql()
global.UserCount = core.InitUserCount()
// 初始化JWT
global.Secret = core.InitJwt()
// 初始化bash
if bash := core.InitCMD(); bash != nil {
global.Bash = bash
} else {
global.Log.Errorf("bash初始化失败")
return
}
// 初始化定时任务
core.InitTimingTask()
// global.CMD = exec.Command("bash")
// // 自动迁移创建表
// err := global.DB.AutoMigrate(&models.TimingTask{})
// if err != nil {
// panic("Failed to migrate TimingTask table: " + err.Error())
// }
// 初始化路由
router := routers.Routers()
// 测试路由
router.GET("/hello", tests.RouteHello())
// tests.CreateUser()
// tests.CreateUserTest()
// tests.DeleteUser("kazusa")
// 从配置项中获得地址并启动服务
addr := global.Config.System.GetAddr()
router.Run(addr)
}