From e4ad9465600b23e27e6c32ae41e97fbc7999dadb Mon Sep 17 00:00:00 2001 From: lijun Date: Tue, 14 Jan 2025 15:49:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index 28b0aef..c36a0b6 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,17 @@ 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 @@ -42,17 +53,6 @@ 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"