refactor: 更新配置文件和代码以优化数据库连接设置
This commit is contained in:
@@ -20,7 +20,7 @@ pprof:
|
||||
rest:
|
||||
- ipv4: 0.0.0.0
|
||||
ipv6:
|
||||
port: 33030
|
||||
port: 33040
|
||||
- ipv4: 0.0.0.0
|
||||
ipv6:
|
||||
port: 33443
|
||||
@@ -40,18 +40,28 @@ webServer:
|
||||
schema: https
|
||||
clientAuthType: 0
|
||||
caFile: ./etc/certs/omc-ca.crt
|
||||
certFile: ./etc/certs/omc-server.crt
|
||||
keyFile: ./etc/certs/omc-server.key
|
||||
certFile: ./etc/certs/omc-web.crt
|
||||
keyFile: ./etc/certs/omc-web.key
|
||||
|
||||
# data sources
|
||||
database:
|
||||
type: mysql
|
||||
user: root
|
||||
password: 1000omc@kp!
|
||||
host: 127.0.0.1
|
||||
port: 33066
|
||||
name: omc_db
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
backup: ./database
|
||||
dataSource:
|
||||
# Default database instance
|
||||
default:
|
||||
type: "mysql"
|
||||
host: "127.0.0.1"
|
||||
port: 33066
|
||||
username: "root"
|
||||
password: "1000omc@kp!"
|
||||
database: "omc_db"
|
||||
logging: true
|
||||
# Built-in lightweight database
|
||||
lite:
|
||||
type: "sqlite"
|
||||
database: "../database/omc_db.sqlite"
|
||||
logging: true
|
||||
# used to specify the default data source for multiple data resourece
|
||||
defaultDataSourceName: "default"
|
||||
|
||||
# Redis data cache
|
||||
redis:
|
||||
@@ -78,7 +88,7 @@ mml:
|
||||
# Tracking configuration
|
||||
trace:
|
||||
enabled: false
|
||||
host: "172.16.5.100" # Fill in the specific IP address
|
||||
host: "127.0.0.1" # Fill in the specific IP address
|
||||
port: 33033
|
||||
|
||||
# NE config
|
||||
@@ -90,8 +100,8 @@ ne:
|
||||
scpdir: /tmp
|
||||
licensedir: /usr/local/etc/{neType}/license
|
||||
# backup etc list of IMS, does not contain spaces
|
||||
etcListIMS: '{*.yaml,mmtel,vars.cfg}'
|
||||
etcListDefault: '{*.yaml,*.conf,*.cfg}'
|
||||
etcListIMS: "{*.yaml,mmtel,vars.cfg}"
|
||||
etcListDefault: "{*.yaml,*.conf,*.cfg}"
|
||||
# true/false to overwrite config file when dpkg ne software
|
||||
dpkgOverwrite: false
|
||||
# dpkg timeout (second)
|
||||
@@ -109,8 +119,8 @@ omc:
|
||||
dn: ""
|
||||
chk2ne: false
|
||||
capability: 50
|
||||
sn: "-"
|
||||
expiryDate: "-"
|
||||
sn: "12345678"
|
||||
expiryDate: "2099-12-31"
|
||||
checksign: false
|
||||
rootDir: /usr/local/omc
|
||||
binDir: /usr/local/omc/bin
|
||||
@@ -190,9 +200,8 @@ params:
|
||||
rmuidregexp: "[0-9]{4}[A-Z]{2}[A-Z]{2}[0-9A-Z]{1}[0-9A-Z]{3}[0-9A-Z]{1,16}"
|
||||
|
||||
testConfig:
|
||||
enabled: true
|
||||
enabled: false
|
||||
file: ./etc/testconfig.yaml
|
||||
|
||||
# 静态文件配置, 相对项目根路径或填绝对路径
|
||||
staticFile:
|
||||
# 默认资源,dir目录需要预先创建
|
||||
|
||||
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
_ "net/http/pprof"
|
||||
@@ -15,14 +14,9 @@ import (
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
|
||||
"be.ems/features"
|
||||
"be.ems/features/dbrest"
|
||||
"be.ems/features/event"
|
||||
"be.ems/features/fm"
|
||||
"be.ems/features/lm"
|
||||
"be.ems/features/mml"
|
||||
"be.ems/features/pm"
|
||||
featuresCfg "be.ems/lib/config"
|
||||
"be.ems/lib/dborm"
|
||||
"be.ems/lib/global"
|
||||
"be.ems/lib/log"
|
||||
"be.ems/lib/routes"
|
||||
@@ -59,6 +53,8 @@ var wg sync.WaitGroup
|
||||
//
|
||||
// @tag.name network_data
|
||||
// @tag.description network data interface
|
||||
// @tag.name network_data/alarm
|
||||
// @tag.description network data alarm interface
|
||||
// @tag.name network_data/kpi
|
||||
// @tag.description network data kpi interface
|
||||
// @tag.name network_data/amf
|
||||
@@ -170,43 +166,6 @@ func loadFeatures(app *gin.Engine) {
|
||||
log.Infof("========================= OMC restagent startup =========================")
|
||||
log.Infof("OMC restagent version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
|
||||
|
||||
err := dborm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
err = dborm.InitGormConnect(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam, true)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.InitGormConnect err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
err = fm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
err = pm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
err = dbrest.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dbrest.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
err = lm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("lm.initDbClient err:", err)
|
||||
os.Exit(4)
|
||||
}
|
||||
|
||||
mml.InitMML()
|
||||
|
||||
// 将 mux.Router 注册到 gin.Engine
|
||||
|
||||
Reference in New Issue
Block a user