Commit 0738d4f3 by 孙龙

init

parent a280fbcd
Showing with 23 additions and 6 deletions
package main
import (
"flag"
"fmt"
"github.com/ichunt2019/go-msgserver/utils/rabbitmq"
"github.com/ichunt2019/logger"
......@@ -45,14 +46,29 @@ func initDb(dns string) (err error) {
return
}
var ConfigDir string
var LogDir string
// 解析命令行参数
func initArgs() {
// worker -config ./worker.json
// worker -h
flag.StringVar(&ConfigDir, "configDir", "", "配置文件")
flag.StringVar(&LogDir, "logDir", "", "日志目录")
flag.Parse()
}
func main() {
initArgs()
//初始化配置文件
util.Init()
util.Init(ConfigDir)
//
logConfig := make(map[string]string)
logConfig["log_path"] = "logs/order/orderSendPurchaseEmail"
logConfig["log_path"] = LogDir+"order/orderSendPurchaseEmail"
logConfig["log_chan_size"] = "1000"
logger.InitLogger("file",logConfig)
logger.Init()
......
......@@ -42,10 +42,11 @@ type ApiDomain struct {
var Configs *Config =new (Config)
func Init(){
func Init(ConfigDir string){
fmt.Println(ConfigDir+"config/config.toml")
var err error
_, err = toml.DecodeFile("config/config.toml",Configs)
_, err = toml.DecodeFile("config/db.toml",Configs)
_, err = toml.DecodeFile(ConfigDir+"config.toml",Configs)
_, err = toml.DecodeFile(ConfigDir+"db.toml",Configs)
if err!=nil{
fmt.Println(err)
}
......@@ -53,7 +54,7 @@ func Init(){
//fmt.Printf("%+v",Configs.Rabbitmq_ichunt)
//fmt.Printf("%+v",Configs.Crm_domain)
//fmt.Printf("%+v",Configs.Ding_msg)
//
//fmt.Printf("%+v",Configs.Crm_domain)
//fmt.Printf("%+v",Configs.Rabbitmq_ichunt)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment