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