config path

test-errcode
wangchuxiao 2 years ago
parent 8bdf86172f
commit a26ca657fe

@ -18,8 +18,9 @@ func main() {
router := api.NewGinRouter() router := api.NewGinRouter()
go third.MinioInit() go third.MinioInit()
ginPort := flag.Int("port", config.Config.Api.GinPort[0], "get ginServerPort from cmd,default 10002 as port") ginPort := flag.Int("port", config.Config.Api.GinPort[0], "get ginServerPort from cmd,default 10002 as port")
configPath := flag.String("config_path", "../config/", "config folder")
flag.Parse() flag.Parse()
config.InitConfig() config.InitConfig(*configPath)
address := "0.0.0.0:" + strconv.Itoa(*ginPort) address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" { if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort) address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
@ -31,3 +32,7 @@ func main() {
panic("api start failed " + err.Error()) panic("api start failed " + err.Error())
} }
} }
func T() {
}

@ -2,6 +2,7 @@ package main
import ( import (
"OpenIM/internal/task" "OpenIM/internal/task"
"OpenIM/pkg/common/config"
"flag" "flag"
"fmt" "fmt"
"time" "time"
@ -11,7 +12,9 @@ func main() {
var userID = flag.String("user_id", "", "userID to clear msg and reset seq") var userID = flag.String("user_id", "", "userID to clear msg and reset seq")
var superGroupID = flag.String("super_group_id", "", "superGroupID to clear msg and reset seq") var superGroupID = flag.String("super_group_id", "", "superGroupID to clear msg and reset seq")
var fixAllSeq = flag.Bool("fix_all_seq", false, "fix seq") var fixAllSeq = flag.Bool("fix_all_seq", false, "fix seq")
var configPath = flag.String("config_path", "../config/", "config folder")
flag.Parse() flag.Parse()
config.InitConfig(*configPath)
fmt.Println(time.Now(), "start cronTask", *userID, *superGroupID) fmt.Println(time.Now(), "start cronTask", *userID, *superGroupID)
task.FixSeq(*userID, *superGroupID, *fixAllSeq) task.FixSeq(*userID, *superGroupID, *fixAllSeq)
} }

@ -2,12 +2,17 @@ package main
import ( import (
"OpenIM/internal/task" "OpenIM/internal/task"
"OpenIM/pkg/common/config"
"flag"
"fmt" "fmt"
"time" "time"
) )
func main() { func main() {
fmt.Println(time.Now(), "start cronTask") fmt.Println(time.Now(), "start cronTask")
var configPath = flag.String("config_path", "../config/", "config folder")
flag.Parse()
config.InitConfig(*configPath)
if err := task.StartCronTask(); err != nil { if err := task.StartCronTask(); err != nil {
panic(err.Error()) panic(err.Error())
} }

@ -18,7 +18,9 @@ func main() {
rpcPort := flag.Int("rpc_port", defaultRpcPorts[0], "rpc listening port") rpcPort := flag.Int("rpc_port", defaultRpcPorts[0], "rpc listening port")
wsPort := flag.Int("ws_port", defaultWsPorts[0], "ws listening port") wsPort := flag.Int("ws_port", defaultWsPorts[0], "ws listening port")
prometheusPort := flag.Int("prometheus_port", defaultPromePorts[0], "PushrometheusPort default listen port") prometheusPort := flag.Int("prometheus_port", defaultPromePorts[0], "PushrometheusPort default listen port")
configPath := flag.String("config_path", "../config/", "config folder")
flag.Parse() flag.Parse()
config.InitConfig(*configPath)
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
fmt.Println("start rpc/msg_gateway server, port: ", *rpcPort, *wsPort, *prometheusPort, ", OpenIM version: ", constant.CurrentVersion, "\n") fmt.Println("start rpc/msg_gateway server, port: ", *rpcPort, *wsPort, *prometheusPort, ", OpenIM version: ", constant.CurrentVersion, "\n")

@ -14,7 +14,9 @@ func main() {
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "MessageTransferPrometheusPort default listen port") prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "MessageTransferPrometheusPort default listen port")
configPath := flag.String("config_path", "../config/", "config folder")
flag.Parse() flag.Parse()
config.InitConfig(*configPath)
log.NewPrivateLog(constant.LogFileName) log.NewPrivateLog(constant.LogFileName)
msgTransfer := msgtransfer.NewMsgTransfer() msgTransfer := msgtransfer.NewMsgTransfer()
fmt.Println("start msg_transfer server ", ", OpenIM version: ", constant.CurrentVersion, "\n") fmt.Println("start msg_transfer server ", ", OpenIM version: ", constant.CurrentVersion, "\n")

@ -14,7 +14,9 @@ func main() {
defaultPorts := config.Config.RpcPort.OpenImPushPort defaultPorts := config.Config.RpcPort.OpenImPushPort
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port") rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "PushrometheusPort default listen port") prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "PushrometheusPort default listen port")
configPath := flag.String("config_path", "../config/", "config folder")
flag.Parse() flag.Parse()
config.InitConfig(*configPath)
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
log.NewPrivateLog(constant.LogFileName) log.NewPrivateLog(constant.LogFileName)

@ -18,7 +18,9 @@ import (
func start(rpcPorts []int, rpcRegisterName string, prometheusPorts []int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options []grpc.ServerOption) error { func start(rpcPorts []int, rpcRegisterName string, prometheusPorts []int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options []grpc.ServerOption) error {
flagRpcPort := flag.Int("port", rpcPorts[0], "get RpcGroupPort from cmd,default 16000 as port") flagRpcPort := flag.Int("port", rpcPorts[0], "get RpcGroupPort from cmd,default 16000 as port")
flagPrometheusPort := flag.Int("prometheus_port", prometheusPorts[0], "groupPrometheusPort default listen port") flagPrometheusPort := flag.Int("prometheus_port", prometheusPorts[0], "groupPrometheusPort default listen port")
configPath := flag.String("config_path", "../config/", "config folder")
flag.Parse() flag.Parse()
config.InitConfig(*configPath)
fmt.Println("start group rpc server, port: ", *flagRpcPort, ", OpenIM version: ", constant.CurrentVersion) fmt.Println("start group rpc server, port: ", *flagRpcPort, ", OpenIM version: ", constant.CurrentVersion)
log.NewPrivateLog(constant.LogFileName) log.NewPrivateLog(constant.LogFileName)
listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", config.Config.ListenIP, *flagRpcPort)) listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", config.Config.ListenIP, *flagRpcPort))

@ -1,7 +1,6 @@
package config package config
import ( import (
"flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -537,10 +536,8 @@ func initConfig(config interface{}, configName, configPath string) {
unmarshalConfig(config, configPath) unmarshalConfig(config, configPath)
} }
func InitConfig() { func InitConfig(configPath string) {
configPath := flag.String("config_path", "../config/", "config folder") initConfig(&Config, "config.yaml", configPath)
flag.Parse() initConfig(&NotificationConfig, "notification.yaml", configPath)
initConfig(&Config, "config.yaml", *configPath)
initConfig(&NotificationConfig, "notification.yaml", *configPath)
Config.Notification = NotificationConfig.Notification Config.Notification = NotificationConfig.Notification
} }

@ -1,21 +1,21 @@
#Don't put the space between "=" #Don't put the space between "="
msg_gateway_name="open_im_msg_gateway" msg_gateway_name="open_im_msg_gateway"
msg_gateway_binary_root="../bin/" msg_gateway_binary_root="../bin/"
msg_gateway_source_root="../cmd/open_im_msg_gateway/" msg_gateway_source_root="../cmd/msggateway/"
msg_name="open_im_msg" msg_name="open_im_msg"
msg_binary_root="../bin/" msg_binary_root="../bin/"
msg_source_root="../cmd/rpc/open_im_msg/" msg_source_root="../cmd/rpc/msg/"
push_name="open_im_push" push_name="open_im_push"
push_binary_root="../bin/" push_binary_root="../bin/"
push_source_root="../cmd/open_im_push/" push_source_root="../cmd/push/"
msg_transfer_name="open_im_msg_transfer" msg_transfer_name="open_im_msg_transfer"
msg_transfer_binary_root="../bin/" msg_transfer_binary_root="../bin/"
msg_transfer_source_root="../cmd/open_im_msg_transfer/" msg_transfer_source_root="../cmd/msgtransfer/"
msg_transfer_service_num=4 msg_transfer_service_num=4
@ -26,23 +26,28 @@ sdk_server_source_root="../cmd/Open-IM-SDK-Core/"
cron_task_name="open_im_cron_task" cron_task_name="open_im_cron_task"
cron_task_binary_root="../bin/" cron_task_binary_root="../bin/"
cron_task_source_root="../cmd/open_im_cron_task/" cron_task_source_root="../cmd/crontask/"
cmd_utils_name="open_im_cmd_utils"
cmd_utils_binary_root="../bin/"
cmd_utils_source_root="../cmd/cmduitls/"
#Global configuration file default dir #Global configuration file default dir
config_path="../config/config.yaml" config_path="../config/config.yaml"
#servicefile dir path #servicefile dir path
service_source_root=( service_source_root=(
#api service file #api service file
../cmd/open_im_api/ ../cmd/api/
#rpc service file #rpc service file
../cmd/rpc/open_im_user/ ../cmd/rpc/user/
../cmd/rpc/open_im_friend/ ../cmd/rpc/friend/
../cmd/rpc/open_im_group/ ../cmd/rpc/group/
../cmd/rpc/open_im_auth/ ../cmd/rpc/auth/
../cmd/rpc/open_im_conversation/ ../cmd/rpc/conversation/
../cmd/open_im_cron_task ../cmd/crontask
../cmd/cmdutils
${msg_gateway_source_root} ${msg_gateway_source_root}
${msg_transfer_source_root} ${msg_transfer_source_root}
${msg_source_root} ${msg_source_root}
@ -60,6 +65,7 @@ service_names=(
open_im_auth open_im_auth
open_im_conversation open_im_conversation
open_im_cron_task open_im_cron_task
open_im_cmd_utils
${msg_gateway_name} ${msg_gateway_name}
${msg_transfer_name} ${msg_transfer_name}
${msg_name} ${msg_name}

Loading…
Cancel
Save