merge: 合并OMC分支
This commit is contained in:
18
src/app.go
18
src/app.go
@@ -8,18 +8,20 @@ import (
|
||||
"nms_cxy/src/framework/errorcatch"
|
||||
"nms_cxy/src/framework/middleware"
|
||||
"nms_cxy/src/framework/middleware/security"
|
||||
"nms_cxy/src/framework/utils/machine"
|
||||
"nms_cxy/src/modules/chart"
|
||||
"nms_cxy/src/modules/common"
|
||||
"nms_cxy/src/modules/crontask"
|
||||
"nms_cxy/src/modules/monitor"
|
||||
networkdata "nms_cxy/src/modules/network_data"
|
||||
networkelement "nms_cxy/src/modules/network_element"
|
||||
nmscxy "nms_cxy/src/modules/nms_cxy"
|
||||
"nms_cxy/src/modules/system"
|
||||
"nms_cxy/src/modules/trace"
|
||||
"nms_cxy/src/modules/ws"
|
||||
|
||||
"github.com/chenjiandongx/ginprom"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
//go:embed assets/*
|
||||
@@ -29,6 +31,13 @@ var assetsDir embed.FS
|
||||
func AppEngine() *gin.Engine {
|
||||
app := initAppEngine()
|
||||
|
||||
// TODO 不建议在主分支中加入
|
||||
// 性能分析监控
|
||||
if promEnabled := config.Get("pprof.enabled"); promEnabled != nil && promEnabled.(bool) {
|
||||
app.Use(ginprom.PromMiddleware(nil))
|
||||
app.GET("/metrics", ginprom.PromHandler(promhttp.Handler()))
|
||||
}
|
||||
|
||||
// 初始全局默认
|
||||
initDefeat(app)
|
||||
|
||||
@@ -38,6 +47,9 @@ func AppEngine() *gin.Engine {
|
||||
// 设置程序内全局资源访问
|
||||
config.SetAssetsDirFS(assetsDir)
|
||||
|
||||
// 首次安装启动记录
|
||||
machine.Launch()
|
||||
|
||||
// 读取服务配置
|
||||
app.ForwardedByClientIP = config.Get("server.proxy").(bool)
|
||||
return app
|
||||
@@ -109,7 +121,7 @@ func initDefeat(app *gin.Engine) {
|
||||
app.NoRoute(func(c *gin.Context) {
|
||||
c.JSON(404, gin.H{
|
||||
"code": 404,
|
||||
"msg": fmt.Sprintf("%s Not Found", c.Request.RequestURI),
|
||||
"msg": fmt.Sprintf("Not Found %s", c.Request.RequestURI),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -124,8 +136,6 @@ func initModulesRoute(app *gin.Engine) {
|
||||
networkelement.Setup(app)
|
||||
// 网元数据模块
|
||||
networkdata.Setup(app)
|
||||
// 北向模块 - 中国星网
|
||||
nmscxy.Setup(app)
|
||||
// 跟踪模块
|
||||
trace.Setup(app)
|
||||
// 图表模块
|
||||
|
||||
Reference in New Issue
Block a user