Merge branch 'lichang' into lite
This commit is contained in:
19
main.go
19
main.go
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user