数据库初始化
This commit is contained in:
parent
f74a401a81
commit
86d0911401
21
main.go
21
main.go
|
|
@ -19,16 +19,6 @@ import (
|
|||
func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
r := gin.Default()
|
||||
err0 := dao.Init()
|
||||
defer dao.Close()
|
||||
if err0 != nil {
|
||||
panic("failed to connect database:" + err0.Error())
|
||||
}
|
||||
err0 = worker.InitRedis()
|
||||
defer worker.CloseRedis()
|
||||
if err0 != nil {
|
||||
panic("failed to connect redis:" + err0.Error())
|
||||
}
|
||||
r.Use(handler.CrosHandler())
|
||||
r.Use(JWTAuthMiddleware()) // 使用 JWT 认证中间件
|
||||
handler.SetUpToolGroup(r) // Tool
|
||||
|
|
@ -52,6 +42,17 @@ func main() {
|
|||
}
|
||||
|
||||
func init() {
|
||||
//数据库初始
|
||||
err0 := dao.Init()
|
||||
defer dao.Close()
|
||||
if err0 != nil {
|
||||
panic("failed to connect database:" + err0.Error())
|
||||
}
|
||||
err0 = worker.InitRedis()
|
||||
defer worker.CloseRedis()
|
||||
if err0 != nil {
|
||||
panic("failed to connect redis:" + err0.Error())
|
||||
}
|
||||
//读取配置文件
|
||||
//文件地址/home/videoplayer/vp.conf
|
||||
configPath := "/home/videoplayer/vp_stream.conf"
|
||||
|
|
|
|||
Loading…
Reference in New Issue