mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-10-04 07:36:57 +08:00
初次提交
This commit is contained in:
52
boot/boot.go
Normal file
52
boot/boot.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package boot
|
||||
|
||||
import (
|
||||
"msm/config"
|
||||
"msm/dao"
|
||||
"msm/log"
|
||||
"msm/service/es"
|
||||
"msm/service/process"
|
||||
"msm/utils"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Boot() {
|
||||
initConfiguration()
|
||||
initEs()
|
||||
initProcess()
|
||||
}
|
||||
|
||||
func initConfiguration() {
|
||||
typeElem := reflect.TypeOf(config.CF).Elem()
|
||||
valueElem := reflect.ValueOf(config.CF).Elem()
|
||||
for i := 0; i < typeElem.NumField(); i++ {
|
||||
typeField := typeElem.Field(i)
|
||||
valueField := valueElem.Field(i)
|
||||
value, err := dao.ConfigDao.GetConfigValue(typeField.Name)
|
||||
if err != nil {
|
||||
value = typeField.Tag.Get("default")
|
||||
}
|
||||
switch typeField.Type.Kind() {
|
||||
case reflect.String:
|
||||
valueField.SetString(value)
|
||||
case reflect.Bool:
|
||||
valueField.SetBool(utils.Unwarp(strconv.ParseBool(value)))
|
||||
case reflect.Float64:
|
||||
valueField.SetFloat(utils.Unwarp(strconv.ParseFloat(value, 64)))
|
||||
case reflect.Int64, reflect.Int:
|
||||
valueField.SetInt(utils.Unwarp(strconv.ParseInt(value, 10, 64)))
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
log.Logger.Debugw("获取配置信息完成", "Configuration", config.CF)
|
||||
}
|
||||
|
||||
func initEs() {
|
||||
es.InitEs()
|
||||
}
|
||||
|
||||
func initProcess() {
|
||||
process.ProcessCtlService.ProcessInit()
|
||||
}
|
Reference in New Issue
Block a user