Merge branch 'lichang' into lite

This commit is contained in:
TsMask
2025-05-23 16:05:37 +08:00
195 changed files with 4924 additions and 3996 deletions

19
main.go
View File

@@ -171,9 +171,9 @@ func loadFeatures(app *gin.Engine) {
conf := featuresCfg.GetYamlConfig()
log.InitLogger(conf.Logger.File, conf.Logger.Duration, conf.Logger.Count, "omc:restagent", featuresCfg.GetLogLevel())
fmt.Printf("OMC Version: %s\n", config.Version)
log.Infof("========================= OMC Startup =========================")
log.Infof("OMC Version: %s %s %s", config.Version, config.BuildTime, config.GoVer)
// fmt.Printf("OMC Version: %s\n", config.Version)
// log.Infof("========================= OMC Startup =========================")
// log.Infof("OMC Version: %s %s %s", config.Version, config.BuildTime, config.GoVer)
mml.InitMML()
@@ -200,19 +200,20 @@ func loadGlobalPre(app *gin.Engine) {
app.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}
//性能分析监控 Prometheus
pprofEnabled := config.Get("pprof.enabled")
if parse.Boolean(pprofEnabled) {
// Prometheus metrics
metricsEnabled := config.Get("metrics")
if parse.Boolean(metricsEnabled) {
// Grafana Monitor 1
m := ginmetrics.GetMonitor()
m.UseWithoutExposingEndpoint(app)
// Grafana Monitor 2
app.Use(ginprom.PromMiddleware(nil))
app.GET("/metrics", ginprom.PromHandler(promhttp.Handler()))
}
// 启用 pprof HTTP服务
pprofAddr := fmt.Sprint(config.Get("pprofAddr"))
if pprofAddr != "" && pprofAddr != "<nil>" {
wg.Add(1)
// 启用pprof HTTP服务
pprofAddr := config.Get("pprof.addr").(string)
go func(addr string) {
defer wg.Done()
fmt.Println(http.ListenAndServe(addr, nil))