mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun
This commit is contained in:
commit
2e1459e29c
@ -131,8 +131,9 @@ rpcregistername: #rpc注册服务名,默认即可
|
||||
log:
|
||||
storageLocation: ../logs/
|
||||
rotationTime: 24
|
||||
remainRotationCount: 5 #日志数量
|
||||
remainLogLevel: 6 #日志级别 6表示全都打印,测试阶段建议设置为6
|
||||
remainRotationCount: 3 #日志数量
|
||||
#日志级别 6表示全都打印,测试阶段建议设置为6
|
||||
remainLogLevel: 6
|
||||
elasticSearchSwitch: false
|
||||
elasticSearchAddr: [ 127.0.0.1:9201 ]
|
||||
elasticSearchUser: ""
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
@ -257,16 +258,16 @@ func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request) bool {
|
||||
status := http.StatusUnauthorized
|
||||
query := r.URL.Query()
|
||||
if len(query["token"]) != 0 && len(query["sendID"]) != 0 && len(query["platformID"]) != 0 {
|
||||
//if ok, err := token_verify.VerifyToken(query["token"][0], query["sendID"][0]); !ok {
|
||||
// e := err.(*constant.ErrInfo)
|
||||
// log.ErrorByKv("Token verify failed", "", "query", query)
|
||||
// w.Header().Set("Sec-Websocket-Version", "13")
|
||||
// http.Error(w, e.ErrMsg, int(e.ErrCode))
|
||||
// return false
|
||||
//} else {
|
||||
log.InfoByKv("Connection Authentication Success", "", "token", query["token"][0], "userID", query["sendID"][0])
|
||||
return true
|
||||
//}
|
||||
if ok, err := token_verify.VerifyToken(query["token"][0], query["sendID"][0]); !ok {
|
||||
e := err.(*constant.ErrInfo)
|
||||
log.ErrorByKv("Token verify failed", "", "query", query)
|
||||
w.Header().Set("Sec-Websocket-Version", "13")
|
||||
http.Error(w, e.ErrMsg, int(e.ErrCode))
|
||||
return false
|
||||
} else {
|
||||
log.InfoByKv("Connection Authentication Success", "", "token", query["token"][0], "userID", query["sendID"][0])
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
log.ErrorByKv("Args err", "", "query", query)
|
||||
w.Header().Set("Sec-Websocket-Version", "13")
|
||||
|
@ -20,6 +20,6 @@ func Init() {
|
||||
}
|
||||
func Run() {
|
||||
//register mysqlConsumerHandler to
|
||||
//go persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(&persistentCH)
|
||||
go persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(&persistentCH)
|
||||
go historyCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyCH)
|
||||
}
|
||||
|
@ -7,12 +7,16 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
push "Open_IM/internal/push/jpush"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -30,7 +34,7 @@ type AtContent struct {
|
||||
|
||||
func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
var wsResult []*pbRelay.SingleMsgToUser
|
||||
//isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush)
|
||||
isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush)
|
||||
log.Debug("Get msg from msg_transfer And push msg", pushMsg.OperationID, "PushData", pushMsg.String())
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||
//Online push message
|
||||
@ -48,66 +52,66 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
}
|
||||
log.InfoByKv("push_result", pushMsg.OperationID, "result", wsResult, "sendData", pushMsg.MsgData)
|
||||
count++
|
||||
//if isOfflinePush && pushMsg.PushToUserID != pushMsg.MsgData.SendID {
|
||||
// for _, v := range wsResult {
|
||||
// if v.ResultCode == 0 {
|
||||
// continue
|
||||
// }
|
||||
// //supported terminal
|
||||
// for _, t := range pushTerminal {
|
||||
// if v.RecvPlatFormID == t {
|
||||
// //Use offline push messaging
|
||||
// var UIDList []string
|
||||
// UIDList = append(UIDList, v.RecvID)
|
||||
// customContent := OpenIMContent{
|
||||
// SessionType: int(pushMsg.MsgData.SessionType),
|
||||
// From: pushMsg.MsgData.SendID,
|
||||
// To: pushMsg.MsgData.RecvID,
|
||||
// Seq: pushMsg.MsgData.Seq,
|
||||
// }
|
||||
// bCustomContent, _ := json.Marshal(customContent)
|
||||
// jsonCustomContent := string(bCustomContent)
|
||||
// var content string
|
||||
// if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||
// content = pushMsg.MsgData.OfflinePushInfo.Title
|
||||
//
|
||||
// } else {
|
||||
// switch pushMsg.MsgData.ContentType {
|
||||
// case constant.Text:
|
||||
// content = constant.ContentType2PushContent[constant.Text]
|
||||
// case constant.Picture:
|
||||
// content = constant.ContentType2PushContent[constant.Picture]
|
||||
// case constant.Voice:
|
||||
// content = constant.ContentType2PushContent[constant.Voice]
|
||||
// case constant.Video:
|
||||
// content = constant.ContentType2PushContent[constant.Video]
|
||||
// case constant.File:
|
||||
// content = constant.ContentType2PushContent[constant.File]
|
||||
// case constant.AtText:
|
||||
// a := AtContent{}
|
||||
// _ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
||||
// if utils.IsContain(v.RecvID, a.AtUserList) {
|
||||
// content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
||||
// } else {
|
||||
// content = constant.ContentType2PushContent[constant.GroupMsg]
|
||||
// }
|
||||
// default:
|
||||
// content = constant.ContentType2PushContent[constant.Common]
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// pushResult, err := push.JGAccountListPush(UIDList, content, jsonCustomContent, constant.PlatformIDToName(t))
|
||||
// if err != nil {
|
||||
// log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error(), constant.PlatformIDToName(t))
|
||||
// } else {
|
||||
// log.NewDebug(pushMsg.OperationID, "offline push return result is ", string(pushResult), pushMsg.MsgData, constant.PlatformIDToName(t))
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
if isOfflinePush && pushMsg.PushToUserID != pushMsg.MsgData.SendID {
|
||||
for _, v := range wsResult {
|
||||
if v.ResultCode == 0 {
|
||||
continue
|
||||
}
|
||||
//supported terminal
|
||||
for _, t := range pushTerminal {
|
||||
if v.RecvPlatFormID == t {
|
||||
//Use offline push messaging
|
||||
var UIDList []string
|
||||
UIDList = append(UIDList, v.RecvID)
|
||||
customContent := OpenIMContent{
|
||||
SessionType: int(pushMsg.MsgData.SessionType),
|
||||
From: pushMsg.MsgData.SendID,
|
||||
To: pushMsg.MsgData.RecvID,
|
||||
Seq: pushMsg.MsgData.Seq,
|
||||
}
|
||||
bCustomContent, _ := json.Marshal(customContent)
|
||||
jsonCustomContent := string(bCustomContent)
|
||||
var content string
|
||||
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||
content = pushMsg.MsgData.OfflinePushInfo.Title
|
||||
|
||||
} else {
|
||||
switch pushMsg.MsgData.ContentType {
|
||||
case constant.Text:
|
||||
content = constant.ContentType2PushContent[constant.Text]
|
||||
case constant.Picture:
|
||||
content = constant.ContentType2PushContent[constant.Picture]
|
||||
case constant.Voice:
|
||||
content = constant.ContentType2PushContent[constant.Voice]
|
||||
case constant.Video:
|
||||
content = constant.ContentType2PushContent[constant.Video]
|
||||
case constant.File:
|
||||
content = constant.ContentType2PushContent[constant.File]
|
||||
case constant.AtText:
|
||||
a := AtContent{}
|
||||
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
||||
if utils.IsContain(v.RecvID, a.AtUserList) {
|
||||
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
||||
} else {
|
||||
content = constant.ContentType2PushContent[constant.GroupMsg]
|
||||
}
|
||||
default:
|
||||
content = constant.ContentType2PushContent[constant.Common]
|
||||
}
|
||||
}
|
||||
|
||||
pushResult, err := push.JGAccountListPush(UIDList, content, jsonCustomContent, constant.PlatformIDToName(t))
|
||||
if err != nil {
|
||||
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error(), constant.PlatformIDToName(t))
|
||||
} else {
|
||||
log.NewDebug(pushMsg.OperationID, "offline push return result is ", string(pushResult), pushMsg.MsgData, constant.PlatformIDToName(t))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//func SendMsgByWS(m *pbChat.WSToMsgSvrChatMsg) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package statistics
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -15,13 +14,13 @@ type Statistics struct {
|
||||
func (s *Statistics) output() {
|
||||
t := time.NewTicker(time.Duration(s.SleepTime) * time.Second)
|
||||
defer t.Stop()
|
||||
var sum uint64
|
||||
//var sum uint64
|
||||
for {
|
||||
sum = *s.Count
|
||||
//sum = *s.Count
|
||||
select {
|
||||
case <-t.C:
|
||||
}
|
||||
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
|
||||
//log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ source ./function.sh
|
||||
list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}')
|
||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||
list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}')
|
||||
logLevel=$(cat $config_path | grep remainLogLevel | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
api_ports=($ports_array)
|
||||
list_to_string $list2
|
||||
@ -26,7 +27,7 @@ fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
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/openIM.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]} -openIM_log_level ${logLevel} >>../logs/openIM.log 2>&1 &
|
||||
|
||||
#Check launched service process
|
||||
sleep 3
|
||||
|
Loading…
x
Reference in New Issue
Block a user