mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
log and scripts optimization
This commit is contained in:
parent
a9bd657543
commit
7d7818bc38
@ -88,12 +88,13 @@ rpcregistername:
|
|||||||
openImPushName: Push
|
openImPushName: Push
|
||||||
openImOnlineMessageRelayName: OnlineMessageRelay
|
openImOnlineMessageRelayName: OnlineMessageRelay
|
||||||
openImGroupName: Group
|
openImGroupName: Group
|
||||||
rpcGetTokenName: Auth
|
openImAuthName: Auth
|
||||||
|
|
||||||
log:
|
log:
|
||||||
storageLocation: ../logs/
|
storageLocation: ../logs/
|
||||||
rotationTime: 12
|
rotationTime: 24
|
||||||
remainRotationCount: 10
|
remainRotationCount: 5
|
||||||
|
remainLogLevel: 6
|
||||||
elasticSearchSwitch: false
|
elasticSearchSwitch: false
|
||||||
elasticSearchAddr: [ 127.0.0.1:9201 ]
|
elasticSearchAddr: [ 127.0.0.1:9201 ]
|
||||||
elasticSearchUser: ""
|
elasticSearchUser: ""
|
||||||
|
@ -26,7 +26,7 @@ fi
|
|||||||
sleep 1
|
sleep 1
|
||||||
cd ${msg_gateway_binary_root}
|
cd ${msg_gateway_binary_root}
|
||||||
for ((i = 0; i < ${#ws_ports[@]}; i++)); do
|
for ((i = 0; i < ${#ws_ports[@]}; i++)); do
|
||||||
nohup ./${msg_gateway_name} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]} >>../logs/${msg_gateway_name}.log 2>&1 &
|
nohup ./${msg_gateway_name} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]} >>../logs/openIM.log 2>&1 &
|
||||||
done
|
done
|
||||||
|
|
||||||
#Check launched service process
|
#Check launched service process
|
||||||
|
@ -16,7 +16,7 @@ fi
|
|||||||
#Waiting port recycling
|
#Waiting port recycling
|
||||||
sleep 1
|
sleep 1
|
||||||
cd ${msg_transfer_binary_root}
|
cd ${msg_transfer_binary_root}
|
||||||
nohup ./${msg_transfer_name} >>../logs/${msg_transfer_name}.log 2>&1 &
|
nohup ./${msg_transfer_name} >>../logs/openIM.log 2>&1 &
|
||||||
#Check launched service process
|
#Check launched service process
|
||||||
check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l`
|
check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l`
|
||||||
if [ $check -eq 1 ]
|
if [ $check -eq 1 ]
|
||||||
|
@ -22,7 +22,7 @@ sleep 1
|
|||||||
cd ${push_binary_root}
|
cd ${push_binary_root}
|
||||||
|
|
||||||
for ((i = 0; i < ${#rpc_ports[@]}; i++)); do
|
for ((i = 0; i < ${#rpc_ports[@]}; i++)); do
|
||||||
nohup ./${push_name} -port ${rpc_ports[$i]} >>../logs/${push_name}.log 2>&1 &
|
nohup ./${push_name} -port ${rpc_ports[$i]} >>../logs/openIM.log 2>&1 &
|
||||||
done
|
done
|
||||||
|
|
||||||
sleep 3
|
sleep 3
|
||||||
|
@ -26,7 +26,7 @@ fi
|
|||||||
#Waiting port recycling
|
#Waiting port recycling
|
||||||
sleep 1
|
sleep 1
|
||||||
cd ${sdk_server_binary_root}
|
cd ${sdk_server_binary_root}
|
||||||
nohup ./${sdk_server_name} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]} >>../logs/${sdk_server_name}.log 2>&1 &
|
nohup ./${sdk_server_name} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]} >>../logs/openIM.log 2>&1 &
|
||||||
|
|
||||||
#Check launched service process
|
#Check launched service process
|
||||||
sleep 3
|
sleep 3
|
||||||
|
@ -8,7 +8,7 @@ need_to_start_server_shell=(
|
|||||||
msg_gateway_start.sh
|
msg_gateway_start.sh
|
||||||
push_start.sh
|
push_start.sh
|
||||||
msg_transfer_start.sh
|
msg_transfer_start.sh
|
||||||
start_sdk_svr.sh
|
sdk_svr_start.sh
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in ${need_to_start_server_shell[*]}; do
|
for i in ${need_to_start_server_shell[*]}; do
|
||||||
|
@ -40,7 +40,7 @@ func newUserRegisterReq(params *paramsUserRegister) *pbAuth.UserRegisterReq {
|
|||||||
|
|
||||||
func UserRegister(c *gin.Context) {
|
func UserRegister(c *gin.Context) {
|
||||||
log.Info("", "", "api user_register init ....")
|
log.Info("", "", "api user_register init ....")
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.RpcGetTokenName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||||
client := pbAuth.NewAuthClient(etcdConn)
|
client := pbAuth.NewAuthClient(etcdConn)
|
||||||
//defer etcdConn.Close()
|
//defer etcdConn.Close()
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ func newUserTokenReq(params *paramsUserToken) *pbAuth.UserTokenReq {
|
|||||||
|
|
||||||
func UserToken(c *gin.Context) {
|
func UserToken(c *gin.Context) {
|
||||||
log.Info("", "", "api user_token init ....")
|
log.Info("", "", "api user_token init ....")
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.RpcGetTokenName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||||
client := pbAuth.NewAuthClient(etcdConn)
|
client := pbAuth.NewAuthClient(etcdConn)
|
||||||
//defer etcdConn.Close()
|
//defer etcdConn.Close()
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"Open_IM/src/api/manage"
|
"Open_IM/src/api/manage"
|
||||||
apiThird "Open_IM/src/api/third"
|
apiThird "Open_IM/src/api/third"
|
||||||
"Open_IM/src/api/user"
|
"Open_IM/src/api/user"
|
||||||
|
"Open_IM/src/common/log"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/src/utils"
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -93,7 +94,7 @@ func main() {
|
|||||||
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
|
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
|
||||||
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid)
|
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid)
|
||||||
}
|
}
|
||||||
|
log.NewPrivateLog("api")
|
||||||
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
r.Run(utils.ServerIP + ":" + strconv.Itoa(*ginPort))
|
r.Run(utils.ServerIP + ":" + strconv.Itoa(*ginPort))
|
||||||
|
@ -71,7 +71,7 @@ type config struct {
|
|||||||
OpenImPushName string `yaml:"openImPushName"`
|
OpenImPushName string `yaml:"openImPushName"`
|
||||||
OpenImOnlineMessageRelayName string `yaml:"openImOnlineMessageRelayName"`
|
OpenImOnlineMessageRelayName string `yaml:"openImOnlineMessageRelayName"`
|
||||||
OpenImGroupName string `yaml:"openImGroupName"`
|
OpenImGroupName string `yaml:"openImGroupName"`
|
||||||
RpcGetTokenName string `yaml:"rpcGetTokenName"`
|
OpenImAuthName string `yaml:"openImAuthName"`
|
||||||
}
|
}
|
||||||
Etcd struct {
|
Etcd struct {
|
||||||
EtcdSchema string `yaml:"etcdSchema"`
|
EtcdSchema string `yaml:"etcdSchema"`
|
||||||
@ -81,6 +81,7 @@ type config struct {
|
|||||||
StorageLocation string `yaml:"storageLocation"`
|
StorageLocation string `yaml:"storageLocation"`
|
||||||
RotationTime int `yaml:"rotationTime"`
|
RotationTime int `yaml:"rotationTime"`
|
||||||
RemainRotationCount uint `yaml:"remainRotationCount"`
|
RemainRotationCount uint `yaml:"remainRotationCount"`
|
||||||
|
RemainLogLevel uint `yaml:"remainLogLevel"`
|
||||||
ElasticSearchSwitch bool `yaml:"elasticSearchSwitch"`
|
ElasticSearchSwitch bool `yaml:"elasticSearchSwitch"`
|
||||||
ElasticSearchAddr []string `yaml:"elasticSearchAddr"`
|
ElasticSearchAddr []string `yaml:"elasticSearchAddr"`
|
||||||
ElasticSearchUser string `yaml:"elasticSearchUser"`
|
ElasticSearchUser string `yaml:"elasticSearchUser"`
|
||||||
|
@ -2,6 +2,7 @@ package log
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/src/common/config"
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
nested "github.com/antonfisher/nested-logrus-formatter"
|
nested "github.com/antonfisher/nested-logrus-formatter"
|
||||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
@ -29,18 +30,25 @@ func NewPrivateLog(moduleName string) {
|
|||||||
func loggerInit(moduleName string) *Logger {
|
func loggerInit(moduleName string) *Logger {
|
||||||
var logger = logrus.New()
|
var logger = logrus.New()
|
||||||
//All logs will be printed
|
//All logs will be printed
|
||||||
logger.SetLevel(logrus.TraceLevel)
|
logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel))
|
||||||
//Log Style Setting
|
//Close std console output
|
||||||
|
src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
writer := bufio.NewWriter(src)
|
||||||
|
logger.SetOutput(writer)
|
||||||
|
//Log Console Print Style Setting
|
||||||
logger.SetFormatter(&nested.Formatter{
|
logger.SetFormatter(&nested.Formatter{
|
||||||
TimestampFormat: "2006-01-02 15:04:05.000",
|
TimestampFormat: "2006-01-02 15:04:05.000",
|
||||||
HideKeys: false,
|
HideKeys: false,
|
||||||
FieldsOrder: []string{"PID"},
|
FieldsOrder: []string{"PID", "FilePath", "OperationID"},
|
||||||
})
|
})
|
||||||
//File name and line number display hook
|
//File name and line number display hook
|
||||||
logger.AddHook(newFileHook())
|
logger.AddHook(newFileHook())
|
||||||
|
|
||||||
//Send logs to elasticsearch hook
|
//Send logs to elasticsearch hook
|
||||||
if config.Config.Log.ElasticSearchSwitch == true {
|
if config.Config.Log.ElasticSearchSwitch {
|
||||||
logger.AddHook(newEsHook(moduleName))
|
logger.AddHook(newEsHook(moduleName))
|
||||||
}
|
}
|
||||||
//Log file segmentation hook
|
//Log file segmentation hook
|
||||||
@ -60,13 +68,16 @@ func NewLfsHook(rotationTime time.Duration, maxRemainNum uint, moduleName string
|
|||||||
}, &nested.Formatter{
|
}, &nested.Formatter{
|
||||||
TimestampFormat: "2006-01-02 15:04:05.000",
|
TimestampFormat: "2006-01-02 15:04:05.000",
|
||||||
HideKeys: false,
|
HideKeys: false,
|
||||||
FieldsOrder: []string{"PID"},
|
FieldsOrder: []string{"PID", "FilePath", "OperationID"},
|
||||||
})
|
})
|
||||||
return lfsHook
|
return lfsHook
|
||||||
}
|
}
|
||||||
func initRotateLogs(rotationTime time.Duration, maxRemainNum uint, level string, moduleName string) *rotatelogs.RotateLogs {
|
func initRotateLogs(rotationTime time.Duration, maxRemainNum uint, level string, moduleName string) *rotatelogs.RotateLogs {
|
||||||
|
if moduleName != "" {
|
||||||
|
moduleName = moduleName + "."
|
||||||
|
}
|
||||||
writer, err := rotatelogs.New(
|
writer, err := rotatelogs.New(
|
||||||
config.Config.Log.StorageLocation+moduleName+"/"+level+"."+"%Y-%m-%d_%H-%M-%S",
|
config.Config.Log.StorageLocation+moduleName+level+"."+"%Y-%m-%d",
|
||||||
rotatelogs.WithRotationTime(rotationTime),
|
rotatelogs.WithRotationTime(rotationTime),
|
||||||
rotatelogs.WithRotationCount(maxRemainNum),
|
rotatelogs.WithRotationCount(maxRemainNum),
|
||||||
)
|
)
|
||||||
@ -77,54 +88,50 @@ func initRotateLogs(rotationTime time.Duration, maxRemainNum uint, level string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
func Info(token, OperationID, format string, args ...interface{}) {
|
func Info(token, OperationID, format string, args ...interface{}) {
|
||||||
if token == "" && OperationID == "" {
|
|
||||||
logger.WithFields(logrus.Fields{}).Infof(format, args...)
|
|
||||||
} else {
|
|
||||||
logger.WithFields(logrus.Fields{
|
logger.WithFields(logrus.Fields{
|
||||||
"token": token,
|
"PID": logger.Pid,
|
||||||
"OperationID": OperationID,
|
"OperationID": OperationID,
|
||||||
}).Infof(format, args...)
|
}).Infof(format, args...)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
func Error(token, OperationID, format string, args ...interface{}) {
|
func Error(token, OperationID, format string, args ...interface{}) {
|
||||||
if token == "" && OperationID == "" {
|
|
||||||
logger.WithFields(logrus.Fields{}).Errorf(format, args...)
|
|
||||||
} else {
|
|
||||||
logger.WithFields(logrus.Fields{
|
logger.WithFields(logrus.Fields{
|
||||||
"token": token,
|
"PID": logger.Pid,
|
||||||
"OperationID": OperationID,
|
"OperationID": OperationID,
|
||||||
}).Errorf(format, args...)
|
}).Errorf(format, args...)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
func Debug(token, OperationID, format string, args ...interface{}) {
|
func Debug(token, OperationID, format string, args ...interface{}) {
|
||||||
if token == "" && OperationID == "" {
|
|
||||||
logger.WithFields(logrus.Fields{}).Debugf(format, args...)
|
|
||||||
} else {
|
|
||||||
logger.WithFields(logrus.Fields{
|
logger.WithFields(logrus.Fields{
|
||||||
"token": token,
|
"PID": logger.Pid,
|
||||||
"OperationID": OperationID,
|
"OperationID": OperationID,
|
||||||
}).Debugf(format, args...)
|
}).Debugf(format, args...)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
func Warning(token, OperationID, format string, args ...interface{}) {
|
func Warning(token, OperationID, format string, args ...interface{}) {
|
||||||
if token == "" && OperationID == "" {
|
|
||||||
logger.WithFields(logrus.Fields{}).Warningf(format, args...)
|
|
||||||
} else {
|
|
||||||
logger.WithFields(logrus.Fields{
|
logger.WithFields(logrus.Fields{
|
||||||
"token": token,
|
"PID": logger.Pid,
|
||||||
"OperationID": OperationID,
|
"OperationID": OperationID,
|
||||||
}).Warningf(format, args...)
|
}).Warningf(format, args...)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
func InfoByArgs(format string, args ...interface{}) {
|
func InfoByArgs(format string, args ...interface{}) {
|
||||||
logger.WithFields(logrus.Fields{}).Infof(format, args)
|
logger.WithFields(logrus.Fields{}).Infof(format, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
func ErrorByArgs(format string, args ...interface{}) {
|
func ErrorByArgs(format string, args ...interface{}) {
|
||||||
logger.WithFields(logrus.Fields{}).Errorf(format, args...)
|
logger.WithFields(logrus.Fields{}).Errorf(format, args...)
|
||||||
}
|
}
|
||||||
@ -132,21 +139,28 @@ func ErrorByArgs(format string, args ...interface{}) {
|
|||||||
//Print log information in k, v format,
|
//Print log information in k, v format,
|
||||||
//kv is best to appear in pairs. tipInfo is the log prompt information for printing,
|
//kv is best to appear in pairs. tipInfo is the log prompt information for printing,
|
||||||
//and kv is the key and value for printing.
|
//and kv is the key and value for printing.
|
||||||
|
//Deprecated
|
||||||
func InfoByKv(tipInfo, OperationID string, args ...interface{}) {
|
func InfoByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||||
fields := make(logrus.Fields)
|
fields := make(logrus.Fields)
|
||||||
argsHandle(OperationID, fields, args)
|
argsHandle(OperationID, fields, args)
|
||||||
logger.WithFields(fields).Info(tipInfo)
|
logger.WithFields(fields).Info(tipInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
func ErrorByKv(tipInfo, OperationID string, args ...interface{}) {
|
func ErrorByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||||
fields := make(logrus.Fields)
|
fields := make(logrus.Fields)
|
||||||
argsHandle(OperationID, fields, args)
|
argsHandle(OperationID, fields, args)
|
||||||
logger.WithFields(fields).Error(tipInfo)
|
logger.WithFields(fields).Error(tipInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
func DebugByKv(tipInfo, OperationID string, args ...interface{}) {
|
func DebugByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||||
fields := make(logrus.Fields)
|
fields := make(logrus.Fields)
|
||||||
argsHandle(OperationID, fields, args)
|
argsHandle(OperationID, fields, args)
|
||||||
logger.WithFields(fields).Debug(tipInfo)
|
logger.WithFields(fields).Debug(tipInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
func WarnByKv(tipInfo, OperationID string, args ...interface{}) {
|
func WarnByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||||
fields := make(logrus.Fields)
|
fields := make(logrus.Fields)
|
||||||
argsHandle(OperationID, fields, args)
|
argsHandle(OperationID, fields, args)
|
||||||
@ -162,6 +176,30 @@ func argsHandle(OperationID string, fields logrus.Fields, args []interface{}) {
|
|||||||
fields[fmt.Sprintf("%v", args[i])] = ""
|
fields[fmt.Sprintf("%v", args[i])] = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fields["operationID"] = OperationID
|
fields["OperationID"] = OperationID
|
||||||
fields["PID"] = logger.Pid
|
fields["PID"] = logger.Pid
|
||||||
}
|
}
|
||||||
|
func NewInfo(OperationID string, args ...interface{}) {
|
||||||
|
logger.WithFields(logrus.Fields{
|
||||||
|
"OperationID": OperationID,
|
||||||
|
"PID": logger.Pid,
|
||||||
|
}).Infoln(args)
|
||||||
|
}
|
||||||
|
func NewError(OperationID string, args ...interface{}) {
|
||||||
|
logger.WithFields(logrus.Fields{
|
||||||
|
"OperationID": OperationID,
|
||||||
|
"PID": logger.Pid,
|
||||||
|
}).Errorln(args)
|
||||||
|
}
|
||||||
|
func NewDebug(OperationID string, args ...interface{}) {
|
||||||
|
logger.WithFields(logrus.Fields{
|
||||||
|
"OperationID": OperationID,
|
||||||
|
"PID": logger.Pid,
|
||||||
|
}).Debugln(args)
|
||||||
|
}
|
||||||
|
func NewWarn(OperationID string, args ...interface{}) {
|
||||||
|
logger.WithFields(logrus.Fields{
|
||||||
|
"OperationID": OperationID,
|
||||||
|
"PID": logger.Pid,
|
||||||
|
}).Warnln(args)
|
||||||
|
}
|
||||||
|
@ -2,7 +2,8 @@ package rpcAuth
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/src/common/config"
|
||||||
log2 "Open_IM/src/common/log"
|
"Open_IM/src/common/log"
|
||||||
|
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||||
pbAuth "Open_IM/src/proto/auth"
|
pbAuth "Open_IM/src/proto/auth"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/src/utils"
|
||||||
@ -20,24 +21,25 @@ type rpcAuth struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewRpcAuthServer(port int) *rpcAuth {
|
func NewRpcAuthServer(port int) *rpcAuth {
|
||||||
|
log.NewPrivateLog("auth")
|
||||||
return &rpcAuth{
|
return &rpcAuth{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.RpcGetTokenName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImAuthName,
|
||||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rpc *rpcAuth) Run() {
|
func (rpc *rpcAuth) Run() {
|
||||||
log2.Info("", "", "rpc get_token init...")
|
log.Info("", "", "rpc get_token init...")
|
||||||
|
|
||||||
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
|
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
|
||||||
listener, err := net.Listen("tcp", address)
|
listener, err := net.Listen("tcp", address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log2.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
|
log.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log2.Info("", "", "listen network success, address = %s", address)
|
log.Info("", "", "listen network success, address = %s", address)
|
||||||
|
|
||||||
//grpc server
|
//grpc server
|
||||||
srv := grpc.NewServer()
|
srv := grpc.NewServer()
|
||||||
@ -48,14 +50,14 @@ func (rpc *rpcAuth) Run() {
|
|||||||
pbAuth.RegisterAuthServer(srv, rpc)
|
pbAuth.RegisterAuthServer(srv, rpc)
|
||||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log2.Error("", "", "register rpc get_token to etcd failed, err = %s", err.Error())
|
log.Error("", "", "register rpc get_token to etcd failed, err = %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log2.Info("", "", "rpc get_token fail, err = %s", err.Error())
|
log.Info("", "", "rpc get_token fail, err = %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log2.Info("", "", "rpc get_token init success")
|
log.Info("", "", "rpc get_token init success")
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package rpcChat
|
|||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/src/common/config"
|
||||||
"Open_IM/src/common/kafka"
|
"Open_IM/src/common/kafka"
|
||||||
log2 "Open_IM/src/common/log"
|
"Open_IM/src/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
pbChat "Open_IM/src/proto/chat"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/src/utils"
|
||||||
@ -22,6 +22,7 @@ type rpcChat struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewRpcChatServer(port int) *rpcChat {
|
func NewRpcChatServer(port int) *rpcChat {
|
||||||
|
log.NewPrivateLog("msg")
|
||||||
rc := rpcChat{
|
rc := rpcChat{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImOfflineMessageName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImOfflineMessageName,
|
||||||
@ -33,15 +34,15 @@ func NewRpcChatServer(port int) *rpcChat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rpc *rpcChat) Run() {
|
func (rpc *rpcChat) Run() {
|
||||||
log2.Info("", "", "rpc get_token init...")
|
log.Info("", "", "rpc get_token init...")
|
||||||
|
|
||||||
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
|
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
|
||||||
listener, err := net.Listen("tcp", address)
|
listener, err := net.Listen("tcp", address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log2.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
|
log.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log2.Info("", "", "listen network success, address = %s", address)
|
log.Info("", "", "listen network success, address = %s", address)
|
||||||
|
|
||||||
//grpc server
|
//grpc server
|
||||||
srv := grpc.NewServer()
|
srv := grpc.NewServer()
|
||||||
@ -52,14 +53,14 @@ func (rpc *rpcChat) Run() {
|
|||||||
pbChat.RegisterChatServer(srv, rpc)
|
pbChat.RegisterChatServer(srv, rpc)
|
||||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log2.Error("", "", "register rpc get_token to etcd failed, err = %s", err.Error())
|
log.Error("", "", "register rpc get_token to etcd failed, err = %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log2.Info("", "", "rpc get_token fail, err = %s", err.Error())
|
log.Info("", "", "rpc get_token fail, err = %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log2.Info("", "", "rpc get_token init success")
|
log.Info("", "", "rpc get_token init success")
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ type friendServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewFriendServer(port int) *friendServer {
|
func NewFriendServer(port int) *friendServer {
|
||||||
|
log.NewPrivateLog("friend")
|
||||||
return &friendServer{
|
return &friendServer{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImFriendName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImFriendName,
|
||||||
|
@ -28,6 +28,7 @@ type groupServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupServer(port int) *groupServer {
|
func NewGroupServer(port int) *groupServer {
|
||||||
|
log.NewPrivateLog("group")
|
||||||
return &groupServer{
|
return &groupServer{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName,
|
||||||
|
@ -22,6 +22,7 @@ type userServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewUserServer(port int) *userServer {
|
func NewUserServer(port int) *userServer {
|
||||||
|
log.NewPrivateLog("user")
|
||||||
return &userServer{
|
return &userServer{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImUserName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImUserName,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user