fix: timezone parse time issue
This commit is contained in:
@@ -621,7 +621,7 @@ func main() {
|
||||
log.Infof("========================= OMC captrace startup =========================")
|
||||
log.Infof("OMC captrace 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.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
os.Exit(2)
|
||||
|
||||
@@ -11,6 +11,17 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type DbConfig struct {
|
||||
Type string `yaml:"type"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Name string `yaml:"name"`
|
||||
ConnParam string `yaml:"connParam,omitempty"`
|
||||
Backup string `yaml:"backup"`
|
||||
}
|
||||
|
||||
// Yaml struct of config
|
||||
type YamlConfig struct {
|
||||
Logger struct {
|
||||
@@ -24,17 +35,20 @@ type YamlConfig struct {
|
||||
Addr string `yaml:"addr"`
|
||||
} `yaml:"gtp"`
|
||||
|
||||
Database struct {
|
||||
Type string `yaml:"type"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Name string `yaml:"name"`
|
||||
} `yaml:"database"`
|
||||
Database DbConfig `yaml:"database"`
|
||||
}
|
||||
|
||||
var YamlConf YamlConfig
|
||||
var YamlConf YamlConfig = NewYamlConfig()
|
||||
|
||||
// set default value for yaml config
|
||||
func NewYamlConfig() YamlConfig {
|
||||
return YamlConfig{
|
||||
Database: DbConfig{
|
||||
Type: "mysql",
|
||||
ConnParam: "charset=utf8mb4&collation=utf8mb4_general_ci&loc=Local",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ReadConfig(configFile string) {
|
||||
yamlFile, err := os.ReadFile(configFile)
|
||||
|
||||
@@ -12,6 +12,17 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type DbConfig struct {
|
||||
Type string `yaml:"type"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Name string `yaml:"name"`
|
||||
ConnParam string `yaml:"connParam,omitempty"`
|
||||
Backup string `yaml:"backup"`
|
||||
}
|
||||
|
||||
// Yaml struct of config
|
||||
type YamlConfig struct {
|
||||
Logger struct {
|
||||
@@ -30,15 +41,7 @@ type YamlConfig struct {
|
||||
Vendor string `yaml:"vendor"`
|
||||
} `yaml:"omc"`
|
||||
|
||||
Database struct {
|
||||
Type string `yaml:"type"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Name string `yaml:"name"`
|
||||
Backup string `yaml:"backup"`
|
||||
} `yaml:"database"`
|
||||
Database DbConfig `yaml:"database"`
|
||||
|
||||
Tasks struct {
|
||||
File string `yaml:"file"`
|
||||
@@ -58,7 +61,17 @@ type YamlConfig struct {
|
||||
} `yaml:"nbi"`
|
||||
}
|
||||
|
||||
var yamlConfig YamlConfig
|
||||
var yamlConfig YamlConfig = NewYamlConfig()
|
||||
|
||||
// set default value for yaml config
|
||||
func NewYamlConfig() YamlConfig {
|
||||
return YamlConfig{
|
||||
Database: DbConfig{
|
||||
Type: "mysql",
|
||||
ConnParam: "charset=utf8mb4&collation=utf8mb4_general_ci&loc=Local",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ReadConfig(configFile string) error {
|
||||
yamlFile, err := os.ReadFile(configFile)
|
||||
|
||||
@@ -17,7 +17,7 @@ func main() {
|
||||
log.Infof("OMC crontask version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
|
||||
|
||||
err := dborm.InitDbClient(yamlConfig.Database.Type, yamlConfig.Database.User, yamlConfig.Database.Password,
|
||||
yamlConfig.Database.Host, yamlConfig.Database.Port, yamlConfig.Database.Name)
|
||||
yamlConfig.Database.Host, yamlConfig.Database.Port, yamlConfig.Database.Name, yamlConfig.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -13,6 +13,17 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type DbConfig struct {
|
||||
Type string `yaml:"type"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Name string `yaml:"name"`
|
||||
ConnParam string `yaml:"connParam,omitempty"`
|
||||
Backup string `yaml:"backup"`
|
||||
}
|
||||
|
||||
// Yaml struct of config
|
||||
type YamlConfig struct {
|
||||
Logger struct {
|
||||
@@ -39,15 +50,7 @@ type YamlConfig struct {
|
||||
MmlHome string `yaml:"mmlHome"`
|
||||
} `yaml:"sshd"`
|
||||
|
||||
Database struct {
|
||||
Type string `yaml:"type"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Name string `yaml:"name"`
|
||||
Backup string `yaml:"backup"`
|
||||
} `yaml:"database"`
|
||||
Database DbConfig `yaml:"database"`
|
||||
|
||||
OMC struct {
|
||||
HttpUri string `yaml:"httpUri"`
|
||||
@@ -55,7 +58,17 @@ type YamlConfig struct {
|
||||
} `yaml:"omc"`
|
||||
}
|
||||
|
||||
var yamlConfig YamlConfig
|
||||
var yamlConfig YamlConfig = NewYamlConfig()
|
||||
|
||||
// set default value for yaml config
|
||||
func NewYamlConfig() YamlConfig {
|
||||
return YamlConfig{
|
||||
Database: DbConfig{
|
||||
Type: "mysql",
|
||||
ConnParam: "charset=utf8mb4&collation=utf8mb4_general_ci&loc=Local",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ReadConfig(configFile string) {
|
||||
yamlFile, err := os.ReadFile(configFile)
|
||||
|
||||
@@ -31,7 +31,7 @@ func init() {
|
||||
log.Infof("========================= OMC sshsvc startup =========================")
|
||||
log.Infof("OMC sshsvc version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
|
||||
db := conf.Database
|
||||
err := dborm.InitDbClient(db.Type, db.User, db.Password, db.Host, db.Port, db.Name)
|
||||
err := dborm.InitDbClient(db.Type, db.User, db.Password, db.Host, db.Port, db.Name, db.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user