-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
51 lines (44 loc) · 880 Bytes
/
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
package main
import (
"MediaWarp/constants"
"MediaWarp/internal/config"
"MediaWarp/internal/logger"
"MediaWarp/internal/router"
"MediaWarp/pkg"
"flag"
"fmt"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
var (
isDebug bool
)
func init() {
printLOGO()
flag.BoolVar(&isDebug, "debug", false, "是否启用调试模式")
flag.Parse()
}
func main() {
if isDebug {
logger.SetLevel(logrus.DebugLevel)
logger.Warning("已启用调试模式")
} else {
gin.SetMode(gin.ReleaseMode)
}
logger.Info("MediaWarp 监听端口:", config.Port)
ginR := router.InitRouter() // 路由初始化
logger.Info("MediaWarp 启动成功")
ginR.Run(config.ListenAddr()) // 启动服务
}
// 打印LOGO
func printLOGO() {
fmt.Print(
constants.LOGO,
pkg.Center(
fmt.Sprintf(" MediaWarp %s 启动中 ", config.Version()),
75,
"=",
),
"\n\n",
)
}