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 startup =========================")
|
||||||
log.Infof("OMC captrace version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
|
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,
|
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 {
|
if err != nil {
|
||||||
fmt.Println("dborm.initDbClient err:", err)
|
fmt.Println("dborm.initDbClient err:", err)
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
|
|||||||
@@ -11,6 +11,17 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"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
|
// Yaml struct of config
|
||||||
type YamlConfig struct {
|
type YamlConfig struct {
|
||||||
Logger struct {
|
Logger struct {
|
||||||
@@ -24,17 +35,20 @@ type YamlConfig struct {
|
|||||||
Addr string `yaml:"addr"`
|
Addr string `yaml:"addr"`
|
||||||
} `yaml:"gtp"`
|
} `yaml:"gtp"`
|
||||||
|
|
||||||
Database struct {
|
Database DbConfig `yaml:"database"`
|
||||||
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"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
func ReadConfig(configFile string) {
|
||||||
yamlFile, err := os.ReadFile(configFile)
|
yamlFile, err := os.ReadFile(configFile)
|
||||||
|
|||||||
@@ -12,6 +12,17 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"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
|
// Yaml struct of config
|
||||||
type YamlConfig struct {
|
type YamlConfig struct {
|
||||||
Logger struct {
|
Logger struct {
|
||||||
@@ -30,15 +41,7 @@ type YamlConfig struct {
|
|||||||
Vendor string `yaml:"vendor"`
|
Vendor string `yaml:"vendor"`
|
||||||
} `yaml:"omc"`
|
} `yaml:"omc"`
|
||||||
|
|
||||||
Database struct {
|
Database DbConfig `yaml:"database"`
|
||||||
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"`
|
|
||||||
|
|
||||||
Tasks struct {
|
Tasks struct {
|
||||||
File string `yaml:"file"`
|
File string `yaml:"file"`
|
||||||
@@ -58,7 +61,17 @@ type YamlConfig struct {
|
|||||||
} `yaml:"nbi"`
|
} `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 {
|
func ReadConfig(configFile string) error {
|
||||||
yamlFile, err := os.ReadFile(configFile)
|
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)
|
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,
|
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 {
|
if err != nil {
|
||||||
fmt.Println("dborm.initDbClient err:", err)
|
fmt.Println("dborm.initDbClient err:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -13,6 +13,17 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"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
|
// Yaml struct of config
|
||||||
type YamlConfig struct {
|
type YamlConfig struct {
|
||||||
Logger struct {
|
Logger struct {
|
||||||
@@ -39,15 +50,7 @@ type YamlConfig struct {
|
|||||||
MmlHome string `yaml:"mmlHome"`
|
MmlHome string `yaml:"mmlHome"`
|
||||||
} `yaml:"sshd"`
|
} `yaml:"sshd"`
|
||||||
|
|
||||||
Database struct {
|
Database DbConfig `yaml:"database"`
|
||||||
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"`
|
|
||||||
|
|
||||||
OMC struct {
|
OMC struct {
|
||||||
HttpUri string `yaml:"httpUri"`
|
HttpUri string `yaml:"httpUri"`
|
||||||
@@ -55,7 +58,17 @@ type YamlConfig struct {
|
|||||||
} `yaml:"omc"`
|
} `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) {
|
func ReadConfig(configFile string) {
|
||||||
yamlFile, err := os.ReadFile(configFile)
|
yamlFile, err := os.ReadFile(configFile)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func init() {
|
|||||||
log.Infof("========================= OMC sshsvc startup =========================")
|
log.Infof("========================= OMC sshsvc startup =========================")
|
||||||
log.Infof("OMC sshsvc version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
|
log.Infof("OMC sshsvc version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
|
||||||
db := conf.Database
|
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 {
|
if err != nil {
|
||||||
fmt.Println("dborm.initDbClient err:", err)
|
fmt.Println("dborm.initDbClient err:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user