From 84c60cd6b62a33c14a44a6fa67c385d322c90a78 Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Thu, 17 Aug 2023 15:57:59 +0800 Subject: [PATCH 01/12] Feature: add api of get server time and the message's read status is incorrect when app reinstalling. (#884) * fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * chore: network mode change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add api of get server time Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: remove go work sum Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: pull message add isRead field Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> Co-authored-by: FGadvancer --- go.mod | 2 +- go.sum | 4 ++-- go.work.sum | 3 +-- internal/api/msg.go | 3 +++ internal/api/route.go | 1 + internal/rpc/msg/sync_msg.go | 3 +++ pkg/common/convert/msg.go | 1 + pkg/common/db/cache/user.go | 3 ++- pkg/rpcclient/notification/user.go | 6 ++++-- scripts/start_all.sh | 3 ++- 10 files changed, 20 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 87cb62369..bdcf4ba01 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( require github.com/google/uuid v1.3.0 require ( - github.com/OpenIMSDK/protocol v0.0.11 + github.com/OpenIMSDK/protocol v0.0.12 github.com/OpenIMSDK/tools v0.0.13 github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible github.com/go-redis/redis v6.15.9+incompatible diff --git a/go.sum b/go.sum index bf86b45e1..bc56bf686 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,8 @@ cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7Biccwk firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4= firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OpenIMSDK/protocol v0.0.11 h1:3sWujfQhO1I1Da1b8UScaZcc0DNunSbNiH3DagZB/AA= -github.com/OpenIMSDK/protocol v0.0.11/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= +github.com/OpenIMSDK/protocol v0.0.12 h1:79rBgpKBF4TMy5tkLH3DQNiZFVmxKMP7VyX+kmJh4d8= +github.com/OpenIMSDK/protocol v0.0.12/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/OpenIMSDK/tools v0.0.13 h1:rcw4HS8S2DPZR9UOBxD8/ol9UBMzXBypzOVEytDRIMo= github.com/OpenIMSDK/tools v0.0.13/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= diff --git a/go.work.sum b/go.work.sum index 76e060d37..bf1661eb9 100644 --- a/go.work.sum +++ b/go.work.sum @@ -221,8 +221,7 @@ cloud.google.com/go/websecurityscanner v1.6.1/go.mod h1:Njgaw3rttgRHXzwCB8kgCYqv cloud.google.com/go/workflows v1.11.1 h1:2akeQ/PgtRhrNuD/n1WvJd5zb7YyuDZrlOanBj2ihPg= cloud.google.com/go/workflows v1.11.1/go.mod h1:Z+t10G1wF7h8LgdY/EmRcQY8ptBD/nvofaL6FqlET6g= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/OpenIMSDK/protocol v0.0.11 h1:3sWujfQhO1I1Da1b8UScaZcc0DNunSbNiH3DagZB/AA= -github.com/OpenIMSDK/protocol v0.0.11/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= +github.com/OpenIMSDK/protocol v0.0.12/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409 h1:DTQ/38ao/CfXsrK0cSAL+h4R/u0VVvfWLZEOlLwEROI= github.com/alecthomas/kingpin/v2 v2.3.1 h1:ANLJcKmQm4nIaog7xdr/id6FM6zm5hHnfZrvtKPxqGg= github.com/alecthomas/kingpin/v2 v2.3.1/go.mod h1:oYL5vtsvEHZGHxU7DMp32Dvx+qL+ptGn6lWaot2vCNE= diff --git a/internal/api/msg.go b/internal/api/msg.go index da749b0ae..9df3a04b6 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -363,3 +363,6 @@ func (m *MessageApi) GetActiveGroup(c *gin.Context) { func (m *MessageApi) SearchMsg(c *gin.Context) { a2r.Call(msg.MsgClient.SearchMessage, m.Client, c) } +func (m *MessageApi) GetServerTime(c *gin.Context) { + a2r.Call(msg.MsgClient.GetServerTime, m.Client, c) +} diff --git a/internal/api/route.go b/internal/api/route.go index 8cf65b03d..0a0201d43 100644 --- a/internal/api/route.go +++ b/internal/api/route.go @@ -187,6 +187,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive msgGroup.POST("/batch_send_msg", m.BatchSendMsg) msgGroup.POST("/check_msg_is_send_success", m.CheckMsgIsSendSuccess) + msgGroup.POST("/get_server_time", m.GetServerTime) } // Conversation conversationGroup := r.Group("/conversation", ParseToken) diff --git a/internal/rpc/msg/sync_msg.go b/internal/rpc/msg/sync_msg.go index 390299dbd..9c06f3c7c 100644 --- a/internal/rpc/msg/sync_msg.go +++ b/internal/rpc/msg/sync_msg.go @@ -188,3 +188,6 @@ func (m *msgServer) SearchMessage(ctx context.Context, req *msg.SearchMessageReq resp.ChatLogsNum = total return resp, nil } +func (m *msgServer) GetServerTime(ctx context.Context, _ *msg.GetServerTimeReq) (*msg.GetServerTimeResp, error) { + return &msg.GetServerTimeResp{ServerTime: utils.GetCurrentTimestampByMill()}, nil +} diff --git a/pkg/common/convert/msg.go b/pkg/common/convert/msg.go index 7708d7535..59070d338 100644 --- a/pkg/common/convert/msg.go +++ b/pkg/common/convert/msg.go @@ -78,6 +78,7 @@ func MsgDB2Pb(msgModel *unrelation.MsgDataModel) *sdkws.MsgData { msg.SendTime = msgModel.SendTime msg.CreateTime = msgModel.CreateTime msg.Status = msgModel.Status + msg.IsRead = msgModel.IsRead msg.Options = msgModel.Options if msgModel.OfflinePush != nil { msg.OfflinePushInfo = &sdkws.OfflinePushInfo{ diff --git a/pkg/common/db/cache/user.go b/pkg/common/db/cache/user.go index fee907575..ce7f18242 100644 --- a/pkg/common/db/cache/user.go +++ b/pkg/common/db/cache/user.go @@ -17,11 +17,12 @@ package cache import ( "context" "encoding/json" - "github.com/OpenIMSDK/protocol/constant" "hash/crc32" "strconv" "time" + "github.com/OpenIMSDK/protocol/constant" + "github.com/OpenIMSDK/protocol/user" "github.com/OpenIMSDK/tools/errs" diff --git a/pkg/rpcclient/notification/user.go b/pkg/rpcclient/notification/user.go index 5712cb053..3b9383323 100644 --- a/pkg/rpcclient/notification/user.go +++ b/pkg/rpcclient/notification/user.go @@ -16,11 +16,13 @@ package notification import ( "context" + + "github.com/OpenIMSDK/protocol/constant" + "github.com/OpenIMSDK/protocol/sdkws" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" - "github.com/OpenIMSDK/protocol/constant" - "github.com/OpenIMSDK/protocol/sdkws" ) type UserNotificationSender struct { diff --git a/scripts/start_all.sh b/scripts/start_all.sh index bb68546c7..81d7f2dac 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -102,7 +102,8 @@ for i in ${need_to_start_server_shell[*]}; do ./$i # Check if the script executed successfully - if [ $? -ne 0 ]; then + if [ $? -ne + ]; then # Print error message and exit echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${i}. Exiting...${COLOR_SUFFIX}" exit -1 From dd5f2d0476089d2d01b73f92e4701c00686b1b9a Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Thu, 17 Aug 2023 16:59:06 +0800 Subject: [PATCH 02/12] fix: check msg-transfer script (#886) * fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * chore: network mode change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add api of get server time Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: remove go work sum Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: pull message add isRead field Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: check msg-transfer script Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> Co-authored-by: FGadvancer --- scripts/check_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_all.sh b/scripts/check_all.sh index ea9c2b5b7..4939057ca 100755 --- a/scripts/check_all.sh +++ b/scripts/check_all.sh @@ -58,7 +58,7 @@ done #Check launched service process check=$(ps aux | grep -w ./${openim_msgtransfer} | grep -v grep | wc -l) -if [ $check -eq ${msg_transfer_service_num} ]; then +if [ $check -ge ${msg_transfer_service_num} ]; then echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTransfer"${COLOR_SUFFIX} else echo $check ${msg_transfer_service_num} From 6f9f7c767c78b244c801ea61c93507f739d01a46 Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Thu, 17 Aug 2023 18:41:32 +0800 Subject: [PATCH 03/12] fix: scripts of start and check update (#887) * fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * chore: network mode change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add api of get server time Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: remove go work sum Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: pull message add isRead field Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: check msg-transfer script Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> Co-authored-by: FGadvancer --- scripts/msg_gateway_start.sh | 2 +- scripts/msg_transfer_start.sh | 6 +++--- scripts/push_start.sh | 6 +++--- scripts/start_all.sh | 4 ++-- scripts/start_cron.sh | 6 +++--- scripts/style_info.sh | 1 + 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh index 49d84fac5..aa9c2f0ff 100755 --- a/scripts/msg_gateway_start.sh +++ b/scripts/msg_gateway_start.sh @@ -78,5 +78,5 @@ if [ $check -ge 1 ]; then echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allNewPid}${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX} else - echo -e ${BACKGROUND_GREEN}${openim_msggateway}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} + exit -1 fi diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh index 46c077c5d..f287ff8fe 100755 --- a/scripts/msg_transfer_start.sh +++ b/scripts/msg_transfer_start.sh @@ -58,15 +58,15 @@ for ((i = 0; i < ${msg_transfer_service_num}; i++)); do done #Check launched service process -check=`ps | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` +check=`ps -axu| grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` if [ $check -ge 1 ] then -newPid=`ps | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` +newPid=`ps -axu| grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` allPorts="" echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim_msgtransfer}${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX} else - echo -e ${BACKGROUND_GREEN}${openim_msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} + exit -1 fi diff --git a/scripts/push_start.sh b/scripts/push_start.sh index b474e1b99..37629c70f 100755 --- a/scripts/push_start.sh +++ b/scripts/push_start.sh @@ -60,9 +60,9 @@ done sleep 3 #Check launched service process -check=$(ps | grep -w ./${push_name} | grep -v grep | wc -l) +check=$(ps -axu| grep -w ./${push_name} | grep -v grep | wc -l) if [ $check -ge 1 ]; then - newPid=$(ps | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + newPid=$(ps -axu| grep -w ./${push_name} | grep -v grep | awk '{print $2}') ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}') allPorts="" @@ -74,5 +74,5 @@ if [ $check -ge 1 ]; then echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX} else - echo -e ${BACKGROUND_GREEN}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} + exit -1 fi diff --git a/scripts/start_all.sh b/scripts/start_all.sh index 81d7f2dac..daba46f6c 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -85,7 +85,7 @@ echo -e "" ./$component_check if [ $? -ne 0 ]; then # Print error message and exit - echo -e "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" + echo -e "${RED_BOLD}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" exit -1 fi @@ -105,7 +105,7 @@ for i in ${need_to_start_server_shell[*]}; do if [ $? -ne ]; then # Print error message and exit - echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${i}. Exiting...${COLOR_SUFFIX}" + echo -e "${RED_PREFIX}${BOLD_PREFIX}Error executing ${i}. Exiting(please check open-im-server/logs/openIM.log)... ${COLOR_SUFFIX}" exit -1 fi done diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh index ddd3661ae..de964fff4 100755 --- a/scripts/start_cron.sh +++ b/scripts/start_cron.sh @@ -50,15 +50,15 @@ nohup ./${cron_task_name} >>$OPENIM_ROOT/logs/openIM.log 2>&1 & #done #Check launched service process -check=`ps | grep -w ./${cron_task_name} | grep -v grep| wc -l` +check=`ps -axu| grep -w ./${cron_task_name} | grep -v grep| wc -l` if [ $check -ge 1 ] then -newPid=`ps | grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'` +newPid=`ps -axu| grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'` allPorts="" echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${cron_task_name}${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX} echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX} else - echo -e ${BACKGROUND_GREEN}${cron_task_name}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} + exit -1 fi diff --git a/scripts/style_info.sh b/scripts/style_info.sh index 452240035..bc04c84b5 100755 --- a/scripts/style_info.sh +++ b/scripts/style_info.sh @@ -61,6 +61,7 @@ function style-info() { BACKGROUND_LIGHT_PURPLE="\033[105m" # Light purple background BACKGROUND_LIGHT_SKY_BLUE="\033[106m" # Light sky blue background BACKGROUND_LIGHT_WHITE="\033[107m" # Light white background + } style-info \ No newline at end of file From b0d940945f4945a1cfb3c2f4c76488c32cc985a4 Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Thu, 17 Aug 2023 19:21:12 +0800 Subject: [PATCH 04/12] fix: script update (#888) * fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * chore: network mode change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add api of get server time Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: remove go work sum Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: pull message add isRead field Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: check msg-transfer script Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> Co-authored-by: FGadvancer --- scripts/start_all.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/start_all.sh b/scripts/start_all.sh index daba46f6c..d01600ff5 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -85,7 +85,7 @@ echo -e "" ./$component_check if [ $? -ne 0 ]; then # Print error message and exit - echo -e "${RED_BOLD}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" + echo -e "${RED_PREFIX}${BOLD_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" exit -1 fi @@ -102,8 +102,7 @@ for i in ${need_to_start_server_shell[*]}; do ./$i # Check if the script executed successfully - if [ $? -ne - ]; then + if [ $? -ne 0]; then # Print error message and exit echo -e "${RED_PREFIX}${BOLD_PREFIX}Error executing ${i}. Exiting(please check open-im-server/logs/openIM.log)... ${COLOR_SUFFIX}" exit -1 From 0c11880326680719a3ea83af675bdc0d9075db49 Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Thu, 17 Aug 2023 19:30:43 +0800 Subject: [PATCH 05/12] fix: script update (#889) * fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * chore: network mode change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add api of get server time Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: remove go work sum Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: pull message add isRead field Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: check msg-transfer script Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> Co-authored-by: FGadvancer --- scripts/start_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start_all.sh b/scripts/start_all.sh index d01600ff5..9159dde9c 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -102,7 +102,7 @@ for i in ${need_to_start_server_shell[*]}; do ./$i # Check if the script executed successfully - if [ $? -ne 0]; then + if [ $? -ne 0 ]; then # Print error message and exit echo -e "${RED_PREFIX}${BOLD_PREFIX}Error executing ${i}. Exiting(please check open-im-server/logs/openIM.log)... ${COLOR_SUFFIX}" exit -1 From 4f1dacabfa5c16b3e4cd0c66d7b6ca87228d6f4a Mon Sep 17 00:00:00 2001 From: EthanForAi <128460220+EthanForAi@users.noreply.github.com> Date: Thu, 17 Aug 2023 20:43:58 +0800 Subject: [PATCH 06/12] Feat/686: add release process (#891) * feat: add pre-release process * docs: add release process --------- Co-authored-by: skiffer-git <44203734@qq.com> --- docs/conversions/version.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/conversions/version.md b/docs/conversions/version.md index 06b2e17cb..490c8e4a7 100644 --- a/docs/conversions/version.md +++ b/docs/conversions/version.md @@ -104,9 +104,21 @@ git merge release-v3.1 # Push the updates to the main branch git push origin main ``` +## Release Process + +``` +Publishing v3.2.0: A Step-by-Step Guide +(1) Create the tag v3.2.0-alpha.0 from the main branch. +(2) Bugs are fixed on the main branch. Once the bugs are resolved, tag the main branch as v3.2.0-rc.0. +(3) After further testing, if v3.2.0-rc.0 is deemed stable, create a branch named release-v3.2 from the tag v3.2.0-rc.0. +(4) From the release-v3.2 branch, create the tag v3.2.0. At this point, the official release of v3.2.0 is complete. + +After the release of v3.2.0, if urgent bugs are discovered, fix them on the release-v3.2 branch. Then, submit two pull requests (PRs) to both the main and release-v3.2 branches. Tag the release-v3.2 branch as v3.2.1. +``` Throughout this process, active communication within the team is pivotal to maintaining transparency and consensus on changes. ## Docker Images Version Management For more details on managing Docker image versions, visit [OpenIM Docker Images Administration](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/images.md). + From 958afd61150f183e3aeb4ea228a02f5b2be6749a Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Thu, 17 Aug 2023 21:22:27 +0800 Subject: [PATCH 07/12] fix: start don't kill old process (#892) * fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * chore: network mode change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add api of get server time Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: remove go work sum Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: pull message add isRead field Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: check msg-transfer script Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: start don't kill old process Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> Co-authored-by: FGadvancer --- scripts/msg_gateway_start.sh | 10 +++++----- scripts/msg_transfer_start.sh | 12 ++++++------ scripts/push_start.sh | 10 +++++----- scripts/start_cron.sh | 10 +++++----- scripts/start_rpc_service.sh | 16 ++++++++-------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh index aa9c2f0ff..f5aa00a4e 100755 --- a/scripts/msg_gateway_start.sh +++ b/scripts/msg_gateway_start.sh @@ -50,11 +50,11 @@ if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then fi #Check if the service exists #If it is exists,kill this process -check=$(ps aux | grep -w ./${openim_msggateway} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${openim_msggateway} | grep -v grep | awk '{print $2}') - kill -9 ${oldPid} -fi +#check=$(ps aux | grep -w ./${openim_msggateway} | grep -v grep | wc -l) +#if [ $check -ge 1 ]; then +# oldPid=$(ps aux | grep -w ./${openim_msggateway} | grep -v grep | awk '{print $2}') +# kill -9 ${oldPid} +#fi #Waiting port recycling sleep 1 cd ${msg_gateway_binary_root} diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh index f287ff8fe..c0a24104a 100755 --- a/scripts/msg_transfer_start.sh +++ b/scripts/msg_transfer_start.sh @@ -37,12 +37,12 @@ prome_ports=($ports_array) #Check if the service exists #If it is exists,kill this process -check=`ps | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -oldPid=`ps | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` - kill -9 $oldPid -fi +#check=`ps | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` +#if [ $check -ge 1 ] +#then +#oldPid=`ps | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` +# kill -9 $oldPid +#fi #Waiting port recycling sleep 1 diff --git a/scripts/push_start.sh b/scripts/push_start.sh index 37629c70f..d3c2f9a8f 100755 --- a/scripts/push_start.sh +++ b/scripts/push_start.sh @@ -44,11 +44,11 @@ prome_ports=($ports_array) #Check if the service exists #If it is exists,kill this process -check=$(ps | grep -w ./${push_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps | grep -w ./${push_name} | grep -v grep | awk '{print $2}') - kill -9 $oldPid -fi +#check=$(ps | grep -w ./${push_name} | grep -v grep | wc -l) +#if [ $check -ge 1 ]; then +# oldPid=$(ps | grep -w ./${push_name} | grep -v grep | awk '{print $2}') +# kill -9 $oldPid +#fi #Waiting port recycling sleep 1 cd ${push_binary_root} diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh index de964fff4..41b86b4a4 100755 --- a/scripts/start_cron.sh +++ b/scripts/start_cron.sh @@ -35,11 +35,11 @@ logs_dir="$OPENIM_ROOT/logs" #Check if the service exists #If it is exists,kill this process check=`ps | grep -w ./${cron_task_name} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -oldPid=`ps | grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'` - kill -9 $oldPid -fi +#if [ $check -ge 1 ] +#then +#oldPid=`ps | grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'` +# kill -9 $oldPid +#fi #Waiting port recycling sleep 1 diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh index 51e13298f..a26f6cf87 100755 --- a/scripts/start_rpc_service.sh +++ b/scripts/start_rpc_service.sh @@ -78,14 +78,14 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do service_name="ps |grep -w ${service_filename[$i]} |grep -v grep" count="${service_name}| wc -l" - if [ $(eval ${count}) -gt 0 ]; then - pid="${service_name}| awk '{print \$2}'" - echo "${service_filename[$i]} service has been started,pid:$(eval $pid)" - echo "killing the service ${service_filename[$i]} pid:$(eval $pid)" - #kill the service that existed - kill -9 $(eval $pid) - sleep 0.5 - fi +# if [ $(eval ${count}) -gt 0 ]; then +# pid="${service_name}| awk '{print \$2}'" +# echo "${service_filename[$i]} service has been started,pid:$(eval $pid)" +# echo "killing the service ${service_filename[$i]} pid:$(eval $pid)" +# #kill the service that existed +# kill -9 $(eval $pid) +# sleep 0.5 +# fi cd $OPENIM_ROOT cd $BIN_DIR # Get the rpc port in the configuration file From 8b365ae49f2a6e148988f878f88d842851b016d1 Mon Sep 17 00:00:00 2001 From: Alan <68671759+hanzhixiao@users.noreply.github.com> Date: Fri, 18 Aug 2023 18:44:18 +0800 Subject: [PATCH 08/12] Searchmsg (#859) * fix:searchmsg Signed-off-by: hanzhixiao <709674996@qq.com> * fix:searchmsg Signed-off-by: hanzhixiao <709674996@qq.com> --------- Signed-off-by: hanzhixiao <709674996@qq.com> --- pkg/common/db/unrelation/msg.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/common/db/unrelation/msg.go b/pkg/common/db/unrelation/msg.go index ce51ca49c..a1594ecc8 100644 --- a/pkg/common/db/unrelation/msg.go +++ b/pkg/common/db/unrelation/msg.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/OpenIMSDK/tools/log" "time" "github.com/OpenIMSDK/protocol/msg" @@ -1166,9 +1167,7 @@ func (m *MsgMongoDriver) searchMessage(ctx context.Context, req *msg.SearchMessa if err != nil { return 0, nil, err } - if len(msgsDocs) == 0 { - return 0, nil, errs.Wrap(mongo.ErrNoDocuments) - } + log.ZDebug(ctx, "query mongoDB", "result", msgsDocs) msgs := make([]*table.MsgInfoModel, 0) for index := range msgsDocs { msgInfo := msgsDocs[index].Msg @@ -1207,7 +1206,9 @@ func (m *MsgMongoDriver) searchMessage(ctx context.Context, req *msg.SearchMessa } start := (req.Pagination.PageNumber - 1) * req.Pagination.ShowNumber n := int32(len(msgs)) - if start+req.Pagination.ShowNumber < n { + if start >= n { + return n, []*table.MsgInfoModel{}, nil + } else if start+req.Pagination.ShowNumber < n { msgs = msgs[start : start+req.Pagination.ShowNumber] } else { msgs = msgs[start:] From 45a0266b20f71648b8e81d52d7e152bed8937642 Mon Sep 17 00:00:00 2001 From: Alan <68671759+hanzhixiao@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:54:13 +0800 Subject: [PATCH 09/12] chore: to map files of chat docker image into the IM server (#897) * docker_script Signed-off-by: hanzhixiao <709674996@qq.com> * docker_script Signed-off-by: hanzhixiao <709674996@qq.com> * docker_script Signed-off-by: hanzhixiao <709674996@qq.com> * docker_script Signed-off-by: hanzhixiao <709674996@qq.com> * docker_script Signed-off-by: hanzhixiao <709674996@qq.com> * docker_script Signed-off-by: hanzhixiao <709674996@qq.com> * docker_script Signed-off-by: hanzhixiao <709674996@qq.com> --------- Signed-off-by: hanzhixiao <709674996@qq.com> --- docker-compose.yaml | 6 +- openim-chat/config/config.yaml | 104 +++++++++ openim-chat/scripts/LICENSE/LICENSE | 201 ++++++++++++++++++ openim-chat/scripts/LICENSE/LICENSE_TEMPLATES | 13 ++ openim-chat/scripts/admin_rpc_start.sh | 65 ++++++ openim-chat/scripts/build.cmd | 14 ++ openim-chat/scripts/build_all_service.sh | 134 ++++++++++++ openim-chat/scripts/build_docker.sh | 36 ++++ openim-chat/scripts/check_all.sh | 49 +++++ openim-chat/scripts/docker_start_all.sh | 101 +++++++++ openim-chat/scripts/function.sh | 32 +++ openim-chat/scripts/githooks/commit-msg | 93 ++++++++ openim-chat/scripts/githooks/pre-commit | 112 ++++++++++ openim-chat/scripts/githooks/pre-push | 120 +++++++++++ openim-chat/scripts/path_info.sh | 80 +++++++ openim-chat/scripts/start.bat | 5 + openim-chat/scripts/start_all.sh | 105 +++++++++ openim-chat/scripts/stop_all.sh | 47 ++++ openim-chat/scripts/style_info.sh | 66 ++++++ scripts/docker_check_service.sh | 3 + tools/component/main.go | 24 +-- 21 files changed, 1395 insertions(+), 15 deletions(-) create mode 100644 openim-chat/config/config.yaml create mode 100644 openim-chat/scripts/LICENSE/LICENSE create mode 100644 openim-chat/scripts/LICENSE/LICENSE_TEMPLATES create mode 100644 openim-chat/scripts/admin_rpc_start.sh create mode 100644 openim-chat/scripts/build.cmd create mode 100644 openim-chat/scripts/build_all_service.sh create mode 100644 openim-chat/scripts/build_docker.sh create mode 100644 openim-chat/scripts/check_all.sh create mode 100644 openim-chat/scripts/docker_start_all.sh create mode 100644 openim-chat/scripts/function.sh create mode 100644 openim-chat/scripts/githooks/commit-msg create mode 100644 openim-chat/scripts/githooks/pre-commit create mode 100644 openim-chat/scripts/githooks/pre-push create mode 100644 openim-chat/scripts/path_info.sh create mode 100644 openim-chat/scripts/start.bat create mode 100644 openim-chat/scripts/start_all.sh create mode 100644 openim-chat/scripts/stop_all.sh create mode 100644 openim-chat/scripts/style_info.sh diff --git a/docker-compose.yaml b/docker-compose.yaml index 84d478cd7..70e1596b0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -125,9 +125,9 @@ services: image: ghcr.io/openimsdk/openim-chat:latest container_name: openim-chat volumes: - - ./_output/openim/openim-chat/logs:/openim/openim-chat/logs - - ./_output/openim/openim-chat/config:/openim/openim-chat/config - - ./_output/openim/openim-chat/scripts:/openim/openim-chat/scripts + - ./openim-chat/logs:/openim/openim-chat/logs + - ./openim-chat/config:/openim/openim-chat/config + - ./openim-chat/scripts:/openim/openim-chat/scripts restart: always depends_on: - mysql diff --git a/openim-chat/config/config.yaml b/openim-chat/config/config.yaml new file mode 100644 index 000000000..20351b344 --- /dev/null +++ b/openim-chat/config/config.yaml @@ -0,0 +1,104 @@ +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 需要先启动OpenIMServer +zookeeper: + schema: openim + zkAddr: + - 127.0.0.1:2181 + username: "" + password: "" + +chatApi: + openImChatApiPort: [ 10008 ] + listenIP: + +adminApi: + openImAdminApiPort: [ 10009 ] + listenIP: + +rpc: + registerIP: #作为rpc启动时,注册到zookeeper的IP,api/gateway能访问到此ip和对应的rpcPort中的端口 + listenIP: #默认为0.0.0.0 + +rpcPort: + openImAdminPort: [ 30200 ] + openImChatPort: [ 30300 ] +rpcRegisterName: + openImAdminName: admin + openImChatName: chat + +# 没有配置表示和OpenIM一致 +mysql: + # address: [ 127.0.0.1:13306 ] #目前仅支持单机 + # username: root #用户名 + # password: openIM123 #密码 + # database: openIM_v2 #不建议修改 + # maxOpenConn: 1000 #最大连接数 + # maxIdleConn: 100 #最大空闲连接数 + # maxLifeTime: 60 #连接可以重复使用的最长时间(秒) + # logLevel: 4 #日志级别 1=slient 2=error 3=warn 4=info + # slowThreshold: 500 #慢语句阈值 (毫秒) + database: openim_enterprise + +# 没有配置表示和OpenIM一致 +log: + storageLocation: ../logs/ #存放目录 +# rotationTime: 24 #日志旋转时间 +# remainRotationCount: 2 #日志数量 +# remainLogLevel: 6 #日志级别 6表示全都打印, +# isStdout: false +# isJson: false +# withStack: false + +# secret: openIM123 +#tokenPolicy: +# expire: 86400 + +verifyCode: + validTime: 300 # 验证码有效时间 + validCount: 5 # 验证码有效次数 + uintTime: 86400 # 单位时间间隔 + maxCount: 10 # 单位时间内最大获取次数 + superCode: "666666" # 超级验证码(只有use为空时使用) + len: 6 # 验证码长度 + use: "" # 使用的验证码服务(use: "ali") + ali: + endpoint: "dysmsapi.aliyuncs.com" + accessKeyId: "" + accessKeySecret: "" + signName: "" + verificationCodeTemplateCode: "" + +# 获取ip的header,没有配置直接获取远程地址 +#proxyHeader: "X-Forwarded-For" + +adminList: + - adminID: admin1 + nickname: chat1 + imAdmin: openIM123456 + - adminID: admin2 + nickname: chat2 + imAdmin: openIM654321 + - adminID: admin3 + nickname: chat3 + imAdmin: openIMAdmin + + +openIMUrl: "http://127.0.0.1:10002" + +redis: + address: [ 127.0.0.1:16379 ] + username: + password: openIM123 \ No newline at end of file diff --git a/openim-chat/scripts/LICENSE/LICENSE b/openim-chat/scripts/LICENSE/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/openim-chat/scripts/LICENSE/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/openim-chat/scripts/LICENSE/LICENSE_TEMPLATES b/openim-chat/scripts/LICENSE/LICENSE_TEMPLATES new file mode 100644 index 000000000..dbc5ce2c8 --- /dev/null +++ b/openim-chat/scripts/LICENSE/LICENSE_TEMPLATES @@ -0,0 +1,13 @@ +Copyright © {{.Year}} {{.Holder}} All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/openim-chat/scripts/admin_rpc_start.sh b/openim-chat/scripts/admin_rpc_start.sh new file mode 100644 index 000000000..f6a638228 --- /dev/null +++ b/openim-chat/scripts/admin_rpc_start.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + + +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/.. + +source $OPENIM_ROOT/scripts/style_info.sh +source $OPENIM_ROOT/scripts/path_info.sh +source $OPENIM_ROOT/scripts/function.sh + +list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') +list2=$(cat $config_path | grep pushPrometheusPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +rpc_ports=($ports_array) +list_to_string $list2 +prome_ports=($ports_array) + +#Check if the service exists +#If it is exists,kill this process +check=$(ps | grep -w ./${push_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 +cd ${push_binary_root} + +for ((i = 0; i < ${#rpc_ports[@]}; i++)); do + nohup ./${push_name} -port ${rpc_ports[$i]} -prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 & +done + +sleep 3 +#Check launched service process +check=$(ps | grep -w ./${push_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + newPid=$(ps | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts="" + + for i in $ports; do + allPorts=${allPorts}"$i " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/openim-chat/scripts/build.cmd b/openim-chat/scripts/build.cmd new file mode 100644 index 000000000..f100073bc --- /dev/null +++ b/openim-chat/scripts/build.cmd @@ -0,0 +1,14 @@ +@echo off + +set "api_apps=admin-api chat-api" +set "rpc_apps=admin-rpc chat-rpc" + +for %%a in (%api_apps%) do ( + go build -o %%a.exe ../cmd/api/%%a/main.go +) + +for %%a in (%rpc_apps%) do ( + go build -o %%a.exe ../cmd/rpc/%%a/main.go +) + +move *exe ../cmd diff --git a/openim-chat/scripts/build_all_service.sh b/openim-chat/scripts/build_all_service.sh new file mode 100644 index 000000000..a424ac7b1 --- /dev/null +++ b/openim-chat/scripts/build_all_service.sh @@ -0,0 +1,134 @@ +#!/usr/bin/env bash + + +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e +set -o pipefail + +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. + +#Include shell font styles and some basic information +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}" + +echo -e "" + +echo -e "${BACKGROUND_BLUE}===============> Building all using make build binary files ${COLOR_SUFFIX}" + +echo -e "" +echo -e "${BOLD_PREFIX}____________________________________________________________ ${COLOR_SUFFIX}" + + +bin_dir="$BIN_DIR" +logs_dir="$OPENIM_ROOT/logs" + +echo "==> bin_dir=$bin_dir" +echo "==> logs_dir=$logs_dir" + + +cd $SCRIPTS_ROOT/.. + +# CPU core number +cpu_count=$(lscpu | grep -e '^CPU(s):' | awk '{print $2}') +echo -e "${GREEN_PREFIX}======> cpu_count=$cpu_count${COLOR_SUFFIX}" + +# Count the number of concurrent compilations (half the number of cpus) +compile_count=$((cpu_count / 2)) + +# Execute 'make build' run the make command for concurrent compilation +make -j$compile_count build + +if [ $? -ne 0 ]; then + echo "make build Error, script exits" + exit 1 +fi + +# Get the current operating system and architecture +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) + +# Select the repository home directory based on the operating system and architecture +if [[ "$OS" == "darwin" ]]; then + if [[ "$ARCH" == "x86_64" ]]; then + REPO_DIR="darwin/amd64" + else + REPO_DIR="darwin/386" + fi +elif [[ "$OS" == "linux" ]]; then + if [[ "$ARCH" == "x86_64" ]]; then + REPO_DIR="linux/amd64" + elif [[ "$ARCH" == "arm64" ]]; then + REPO_DIR="linux/arm64" + elif [[ "$ARCH" == "mips64" ]]; then + REPO_DIR="linux/mips64" + elif [[ "$ARCH" == "mips64le" ]]; then + REPO_DIR="linux/mips64le" + elif [[ "$ARCH" == "ppc64le" ]]; then + REPO_DIR="linux/ppc64le" + elif [[ "$ARCH" == "s390x" ]]; then + REPO_DIR="linux/s390x" + else + REPO_DIR="linux/386" + fi +elif [[ "$OS" == "windows" ]]; then + if [[ "$ARCH" == "x86_64" ]]; then + REPO_DIR="windows/amd64" + else + REPO_DIR="windows/386" + fi +else + echo -e "${RED_PREFIX}Unsupported OS: $OS${COLOR_SUFFIX}" + exit 1 +fi + +# Determine if all scripts were successfully built +BUILD_SUCCESS=true +FAILED_SCRIPTS=() + +for binary in $(find _output/bin/platforms/$REPO_DIR -type f); do + if [[ ! -x $binary ]]; then + FAILED_SCRIPTS+=("$binary") + BUILD_SUCCESS=false + fi +done + +echo -e " " + +echo -e "${BOLD_PREFIX}=====================> Build Results <=====================${COLOR_SUFFIX}" + +echo -e " " + +if [[ "$BUILD_SUCCESS" == true ]]; then + echo -e "${GREEN_PREFIX}All binaries built successfully.${COLOR_SUFFIX}" +else + echo -e "${RED_PREFIX}Some binary builds failed. Please check the following binary files:${COLOR_SUFFIX}" + for script in "${FAILED_SCRIPTS[@]}"; do + echo -e "${RED_PREFIX}$script${COLOR_SUFFIX}" + done +fi + +echo -e " " + +echo -e "${BOLD_PREFIX}============================================================${COLOR_SUFFIX}" + +echo -e " " diff --git a/openim-chat/scripts/build_docker.sh b/openim-chat/scripts/build_docker.sh new file mode 100644 index 000000000..fcd1452d9 --- /dev/null +++ b/openim-chat/scripts/build_docker.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + + +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/.. + + +IMAGE_VERSION=v1.1.0 +image=openim/openim_chat:$IMAGE_VERSION + + +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +chmod +x $OPENIM_ROOT/scripts/*.sh + +$OPENIM_ROOT/scripts/build_all_service.sh + +docker build -t $image . -f $OPENIM_ROOT/deploy.Dockerfile + +docker push $image + +echo -e ${YELLOW_PREFIX}"docker build success"${COLOR_SUFFIX} diff --git a/openim-chat/scripts/check_all.sh b/openim-chat/scripts/check_all.sh new file mode 100644 index 000000000..7e3f9d616 --- /dev/null +++ b/openim-chat/scripts/check_all.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + + +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/.. + +#Include shell font styles and some basic information +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +service_port_name=( + openImChatApiPort + openImAdminApiPort + #api port name + openImAdminPort + openImChatPort +) + +switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}') +for i in ${service_port_name[*]}; do + list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}') + list_to_string $list + for j in ${ports_array}; do + port=$(ss -tunlp| grep -E 'api|rpc|open_im' | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}') + if [[ ${port} -ne ${j} ]]; then + echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} + exit -1 + else + echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX} + fi + done +done \ No newline at end of file diff --git a/openim-chat/scripts/docker_start_all.sh b/openim-chat/scripts/docker_start_all.sh new file mode 100644 index 000000000..21b2c6f87 --- /dev/null +++ b/openim-chat/scripts/docker_start_all.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash + +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#!/usr/bin/env bash + + +# Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. + +source "$SCRIPTS_ROOT/style_info.sh" +source "$SCRIPTS_ROOT/path_info.sh" +source "$SCRIPTS_ROOT/function.sh" + +printf "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=%s${COLOR_SUFFIX}\n" "$SCRIPTS_ROOT" +printf "${YELLOW_PREFIX}=======>OPENIM_ROOT=%s${COLOR_SUFFIX}\n" "$OPENIM_ROOT" +printf "${YELLOW_PREFIX}=======>pwd=%s${COLOR_SUFFIX}\n" "$PWD" + +bin_dir="$BIN_DIR" +logs_dir="$SCRIPTS_ROOT/../logs" + +printf "${YELLOW_PREFIX}=======>bin_dir=%s${COLOR_SUFFIX}\n" "$bin_dir" +printf "${YELLOW_PREFIX}=======>logs_dir=%s${COLOR_SUFFIX}\n" "$logs_dir" +printf "${YELLOW_PREFIX}=======>sdk_db_dir=%s${COLOR_SUFFIX}\n" "$sdk_db_dir" + +# Service filenames +service_filenames=( + chat-api + admin-api + #rpc + admin-rpc + chat-rpc +) + +# Service config port names +service_port_names=( + openImChatApiPort + openImAdminApiPort + #api port name + openImAdminPort + openImChatPort +) + +service_prometheus_port_names=() + +cd "$SCRIPTS_ROOT" + +# Function to kill a service +kill_service() { + local service_name=$1 + local pid=$(pgrep -f "$service_name") + if [ -n "$pid" ]; then + echo "$service_name service has been started, pid: $pid" + echo "Killing the service $service_name, pid: $pid" + killall "$service_name" + sleep 0.5 + fi +} + +for ((i = 0; i < ${#service_filenames[*]}; i++)); do + service_name="${service_filenames[$i]}" + kill_service "$service_name" + cd "$SCRIPTS_ROOT" + + # Get the rpc ports from the configuration file + readarray -t portList < "$config_path" + service_ports=() + for line in "${portList[@]}"; do + if [[ $line == *"${service_port_names[$i]}"* ]]; then + port=$(echo "$line" | awk -F ':' '{print $NF}') + service_ports+=("$port") + fi + done + + # Start related rpc services based on the number of ports + for port in "${service_ports[@]}"; do + # Start the service in the background + cmd="$bin_dir/$service_name -port $port --config_folder_path $config_path" + if [[ $i -eq 0 || $i -eq 1 ]]; then + cmd="$bin_dir/$service_name -port $port --config_folder_path $config_path" + fi + echo "$cmd" + nohup "$cmd" >> "${logs_dir}/openIM.log" 2>&1 & + sleep 1 + done +done + +sleep infinity diff --git a/openim-chat/scripts/function.sh b/openim-chat/scripts/function.sh new file mode 100644 index 000000000..65209049a --- /dev/null +++ b/openim-chat/scripts/function.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + + +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#input:[10023,2323,3434] +#output:10023 2323 3434 +list_to_string(){ + ports_list=$* + sub_s1=`echo $ports_list | sed 's/ //g'` + sub_s2=${sub_s1//,/ } + sub_s3=${sub_s2#*[} + sub_s4=${sub_s3%]*} + ports_array=$sub_s4 +} + +remove_space(){ + value=$* + result=`echo $value | sed 's/ //g'` +} \ No newline at end of file diff --git a/openim-chat/scripts/githooks/commit-msg b/openim-chat/scripts/githooks/commit-msg new file mode 100644 index 000000000..c7b130cd8 --- /dev/null +++ b/openim-chat/scripts/githooks/commit-msg @@ -0,0 +1,93 @@ +#!/usr/bin/env bash + +# Copyright © 2023 OpenIMSDK. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== +# +# Store this file as .git/hooks/commit-msg in your repository in order to +# enforce checking for proper commit message format before actual commits. +# You may need to make the scripts executable by 'chmod +x .git/hooks/commit-msg'. + +# commit-msg use go-gitlint tool, install go-gitlint via `go get github.com/llorllale/go-gitlint/cmd/go-gitlint` +# go-gitlint --msg-file="$1" + +# An example hook scripts to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. + +YELLOW="\e[93m" +GREEN="\e[32m" +RED="\e[31m" +ENDCOLOR="\e[0m" + +printMessage() { + printf "${YELLOW}OpenIM : $1${ENDCOLOR}\n" +} + +printSuccess() { + printf "${GREEN}OpenIM : $1${ENDCOLOR}\n" +} + +printError() { + printf "${RED}OpenIM : $1${ENDCOLOR}\n" +} + +printMessage "Running the OpenIM commit-msg hook." + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} + +# TODO: go-gitlint dir set +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. +GITLINT_DIR="$OPENIM_ROOT/_output/tools/go-gitlint" + +$GITLINT_DIR \ + --msg-file=$1 \ + --subject-regex="^(build|chore|ci|docs|feat|feature|fix|perf|refactor|revert|style|bot|test)(.*)?:\s?.*" \ + --subject-maxlen=150 \ + --subject-minlen=10 \ + --body-regex=".*" \ + --max-parents=1 + +if [ $? -ne 0 ] +then + if ! command -v $GITLINT_DIR &>/dev/null; then + printError "$GITLINT_DIR not found. Please run 'make tools' OR 'make tools.verify.go-gitlint' make verto install it." + fi + printError "Please fix your commit message to match kubecub coding standards" + printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md" + exit 1 +fi + +### Add Sign-off-by line to the end of the commit message +# Get local git config +NAME=$(git config user.name) +EMAIL=$(git config user.email) + +# Check if the commit message contains a sign-off line +grep -qs "^Signed-off-by: " "$1" +SIGNED_OFF_BY_EXISTS=$? + +# Add "Signed-off-by" line if it doesn't exist +if [ $SIGNED_OFF_BY_EXISTS -ne 0 ]; then + echo -e "\nSigned-off-by: $NAME <$EMAIL>" >> "$1" +fi \ No newline at end of file diff --git a/openim-chat/scripts/githooks/pre-commit b/openim-chat/scripts/githooks/pre-commit new file mode 100644 index 000000000..9c44ecb05 --- /dev/null +++ b/openim-chat/scripts/githooks/pre-commit @@ -0,0 +1,112 @@ +#!/usr/bin/env bash + +# Copyright © 2023 OpenIMSDK. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== +# This is a pre-commit hook that ensures attempts to commit files that are +# are larger than $limit to your _local_ repo fail, with a helpful error message. + +# You can override the default limit of 2MB by supplying the environment variable: +# GIT_FILE_SIZE_LIMIT=50000000 git commit -m "test: this commit is allowed file sizes up to 50MB" +# +# ============================================================================== +# + +LC_ALL=C + +local_branch="$(git rev-parse --abbrev-ref HEAD)" +valid_branch_regex="^(main|master|develop|release(-[a-zA-Z0-9._-]+)?)$|(feature|feat|openim|hotfix|test|bug|bot|ci|cicd|style|)\/[a-z0-9._-]+$|^HEAD$" + +YELLOW="\e[93m" +GREEN="\e[32m" +RED="\e[31m" +ENDCOLOR="\e[0m" + +printMessage() { + printf "${YELLOW}openim : $1${ENDCOLOR}\n" +} + +printSuccess() { + printf "${GREEN}openim : $1${ENDCOLOR}\n" +} + +printError() { + printf "${RED}openim : $1${ENDCOLOR}\n" +} + +printMessage "Running local openim pre-commit hook." + +# flutter format . +# https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md +# TODO! GIT_FILE_SIZE_LIMIT=50000000 git commit -m "test: this commit is allowed file sizes up to 50MB" +# Maximum file size limit in bytes +limit=${GIT_FILE_SIZE_LIMIT:-2000000} # Default 2MB +limitInMB=$(( $limit / 1000000 )) + +function file_too_large(){ + filename=$0 + filesize=$(( $1 / 2**20 )) + + cat < /dev/null 2>&1 +then + against=HEAD +else + against="$empty_tree" +fi + +# Set split so that for loop below can handle spaces in file names by splitting on line breaks +IFS=' +' + +shouldFail=false +for file in $( git diff-index --cached --name-only $against ); do + file_size=$(([ ! -f $file ] && echo 0) || (ls -la $file | awk '{ print $5 }')) + if [ "$file_size" -gt "$limit" ]; then + printError "File $file is $(( $file_size / 10**6 )) MB, which is larger than our configured limit of $limitInMB MB" + shouldFail=true + fi +done + +if $shouldFail +then + printMessage "If you really need to commit this file, you can override the size limit by setting the GIT_FILE_SIZE_LIMIT environment variable, e.g. GIT_FILE_SIZE_LIMIT=42000000 for 42MB. Or, commit with the --no-verify switch to skip the check entirely." + printError "Commit aborted" + exit 1; +fi + +if [[ ! $local_branch =~ $valid_branch_regex ]] +then + printError "There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. +Your commit will be rejected. You should rename your branch to a valid name(feat/name OR bug/name) and try again." + printError "For more on this, read on: https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694" + exit 1 +fi \ No newline at end of file diff --git a/openim-chat/scripts/githooks/pre-push b/openim-chat/scripts/githooks/pre-push new file mode 100644 index 000000000..297cadc73 --- /dev/null +++ b/openim-chat/scripts/githooks/pre-push @@ -0,0 +1,120 @@ +#!/usr/bin/env bash + +# Copyright © 2023 OpenIMSDK. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== +# + +YELLOW="\e[93m" +GREEN="\e[32m" +RED="\e[31m" +ENDCOLOR="\e[0m" + +local_branch="$(git rev-parse --abbrev-ref HEAD)" +valid_branch_regex="^(main|master|develop|release(-[a-zA-Z0-9._-]+)?)$|(feature|feat|openim|hotfix|test|bug|ci|cicd|style|)\/[a-z0-9._-]+$|^HEAD$" + +printMessage() { + printf "${YELLOW}OpenIM : $1${ENDCOLOR}\n" +} + +printSuccess() { + printf "${GREEN}OpenIM : $1${ENDCOLOR}\n" +} + +printError() { + printf "${RED}OpenIM : $1${ENDCOLOR}\n" +} + +printMessage "Running local OpenIM pre-push hook." + +if [[ `git status --porcelain` ]]; then + printError "This scripts needs to run against committed code only. Please commit or stash you changes." + exit 1 +fi + +COLOR_SUFFIX="\033[0m" + +BLACK_PREFIX="\033[30m" +RED_PREFIX="\033[31m" +GREEN_PREFIX="\033[32m" +BACKGROUND_GREEN="\033[33m" +BLUE_PREFIX="\033[34m" +PURPLE_PREFIX="\033[35m" +SKY_BLUE_PREFIX="\033[36m" +WHITE_PREFIX="\033[37m" +BOLD_PREFIX="\033[1m" +UNDERLINE_PREFIX="\033[4m" +ITALIC_PREFIX="\033[3m" + +# Function to print colored text +print_color() { + local text=$1 + local color=$2 + echo -e "${color}${text}${COLOR_SUFFIX}" +} + +# Function to print section separator +print_separator() { + print_color "==========================================================" ${PURPLE_PREFIX} +} + +# Get current time +time=$(date +"%Y-%m-%d %H:%M:%S") + +# Print section separator +print_separator + +# Print time of submission +print_color "PTIME: ${time}" "${BOLD_PREFIX}${CYAN_PREFIX}" +echo "" +author=$(git config user.name) +repository=$(basename -s .git $(git config --get remote.origin.url)) + +# Print additional information if needed +print_color "Repository: ${repository}" "${BLUE_PREFIX}" +echo "" + +print_color "Author: ${author}" "${PURPLE_PREFIX}" + +# Print section separator +print_separator + +file_list=$(git diff --name-status HEAD @{u}) +added_files=$(grep -c '^A' <<< "$file_list") +modified_files=$(grep -c '^M' <<< "$file_list") +deleted_files=$(grep -c '^D' <<< "$file_list") + +print_color "Added Files: ${added_files}" "${BACKGROUND_GREEN}" +print_color "Modified Files: ${modified_files}" "${BACKGROUND_GREEN}" +print_color "Deleted Files: ${deleted_files}" "${BACKGROUND_GREEN}" + +if [[ ! $local_branch =~ $valid_branch_regex ]] +then + printError "There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. +Your commit will be rejected. You should rename your branch to a valid name(feat/name OR bug/name) and try again." + printError "For more on this, read on: https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694" + exit 1 +fi + +# +#printMessage "Running the Flutter analyzer" +#flutter analyze +# +#if [ $? -ne 0 ]; then +# printError "Flutter analyzer error" +# exit 1 +#fi +# +#printMessage "Finished running the Flutter analyzer" diff --git a/openim-chat/scripts/path_info.sh b/openim-chat/scripts/path_info.sh new file mode 100644 index 000000000..5a8a0854d --- /dev/null +++ b/openim-chat/scripts/path_info.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +#Don't put the space between "=" + +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. + +# Determine the architecture and version +architecture=$(uname -m) +version=$(uname -s | tr '[:upper:]' '[:lower:]') + +#Include shell font styles and some basic information +source $SCRIPTS_ROOT/style_info.sh + +cd $SCRIPTS_ROOT + +# Define the supported architectures and corresponding bin directories +declare -A supported_architectures=( + ["linux-amd64"]="_output/bin/platforms/linux/amd64" + ["linux-arm64"]="_output/bin/platforms/linux/arm64" + ["linux-mips64"]="_output/bin/platforms/linux/mips64" + ["linux-mips64le"]="_output/bin/platforms/linux/mips64le" + ["linux-ppc64le"]="_output/bin/platforms/linux/ppc64le" + ["linux-s390x"]="_output/bin/platforms/linux/s390x" + ["darwin-amd64"]="_output/bin/platforms/darwin/amd64" + ["windows-amd64"]="_output/bin/platforms/windows/amd64" + ["linux-x86_64"]="_output/bin/platforms/linux/amd64" # Alias for linux-amd64 + ["darwin-x86_64"]="_output/bin/platforms/darwin/amd64" # Alias for darwin-amd64 +) + +# Check if the architecture and version are supported +if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then + echo -e "${BLUE_PREFIX}================> Unsupported architecture: $architecture or version: $version${COLOR_SUFFIX}" + exit 1 +fi + +echo -e "${BLUE_PREFIX}================> Architecture: $architecture${COLOR_SUFFIX}" + +# Set the BIN_DIR based on the architecture and version +BIN_DIR=${SCRIPTS_ROOT}/../${supported_architectures["$version-$architecture"]} + +echo -e "${BLUE_PREFIX}================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR${COLOR_SUFFIX}" + +#Global configuration file default dir +config_path="$OPENIM_ROOT/config/config.yaml" +configfile_path="$OPENIM_ROOT/config" +log_path="$OPENIM_ROOT/log" + +#servicefile dir path +service_source_root=( + #api service file + $OPENIM_ROOT/cmd/api/chat-api/ + $OPENIM_ROOT/cmd/api/admin-api/ + #rpc service file + $OPENIM_ROOT/cmd/rpc/admin-rpc/ + $OPENIM_ROOT/cmd/rpc/chat-rpc/ +) +#service filename +service_names=( + chat-api + admin-api + chat-rpc + admin-rpc +) diff --git a/openim-chat/scripts/start.bat b/openim-chat/scripts/start.bat new file mode 100644 index 000000000..2c765f10d --- /dev/null +++ b/openim-chat/scripts/start.bat @@ -0,0 +1,5 @@ +cd /d %~dp0../cmd +start admin-rpc.exe +start chat-rpc.exe +start chat-api.exe +start admin-api.exe \ No newline at end of file diff --git a/openim-chat/scripts/start_all.sh b/openim-chat/scripts/start_all.sh new file mode 100644 index 000000000..b2ee16214 --- /dev/null +++ b/openim-chat/scripts/start_all.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e +set -o pipefail + +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/.. + +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}" + +# if [ ! -d "${OPENIM_ROOT}/_output/bin/platforms" ]; then +# cd $OPENIM_ROOT +# # exec build_all_service.sh +# "${SCRIPTS_ROOT}/build_all_service.sh" +# fi + +bin_dir="$BIN_DIR" +logs_dir="$SCRIPTS_ROOT/../logs" + +echo -e "${YELLOW_PREFIX}=======>bin_dir=$bin_dir${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>logs_dir=$logs_dir${COLOR_SUFFIX}" + +#service filename +service_filename=( + chat-api + admin-api + #rpc + admin-rpc + chat-rpc +) + +#service config port name +service_port_name=( +openImChatApiPort +openImAdminApiPort + #api port name + openImAdminPort + openImChatPort +) + +service_prometheus_port_name=( + +) + +# Automatically created when there is no bin, logs folder +if [ ! -d $logs_dir ]; then + mkdir -p $logs_dir +fi +cd $SCRIPTS_ROOT + +for ((i = 0; i < ${#service_filename[*]}; i++)); do + #Check whether the service exists +# service_name="ps |grep -w ${service_filename[$i]} |grep -v grep" +# count="${service_name}| wc -l" +# +# if [ $(eval ${count}) -gt 0 ]; then +# pid="${service_name}| awk '{print \$2}'" +# echo "${service_filename[$i]} service has been started,pid:$(eval $pid)" +# echo "killing the service ${service_filename[$i]} pid:$(eval $pid)" +# #kill the service that existed +# kill -9 $(eval $pid) +# sleep 0.5 +# fi + cd $SCRIPTS_ROOT + + #Get the rpc port in the configuration file + portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}') + list_to_string ${portList} + service_ports=($ports_array) + + #Start related rpc services based on the number of ports + for ((j = 0; j < ${#service_ports[*]}; j++)); do + #Start the service in the background + cmd="$bin_dir/${service_filename[$i]} -port ${service_ports[$j]} --config_folder_path ${config_path}" + if [ $i -eq 0 -o $i -eq 1 ]; then + cmd="$bin_dir/${service_filename[$i]} -port ${service_ports[$j]} --config_folder_path ${config_path}" + fi + echo $cmd + nohup $cmd >>${logs_dir}/openIM.log 2>&1 & + sleep 1 +# pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" +# echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:${service_ports[$j]} pid:$(eval $pid)$COLOR_SUFFIX" + done +done \ No newline at end of file diff --git a/openim-chat/scripts/stop_all.sh b/openim-chat/scripts/stop_all.sh new file mode 100644 index 000000000..6e69ba53f --- /dev/null +++ b/openim-chat/scripts/stop_all.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#fixme This scripts is to stop the service +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(cd $(dirname "${BASH_SOURCE[0]}")/.. &&pwd) + +source $OPENIM_ROOT/scripts/style_info.sh +source $OPENIM_ROOT/scripts/path_info.sh +source $SCRIPTS_ROOT/function.sh + +service_port_name=( + openImChatApiPort + openImAdminApiPort + #api port name + openImAdminPort + openImChatPort +) + +for i in ${service_port_name[*]}; do + list=$(cat $OPENIM_ROOT/config/config.yaml | grep -w ${i} | awk -F '[:]' '{print $NF}') + list_to_string $list + for j in ${ports_array}; do + name="ps -aux |grep -w $j |grep -v grep" + count="${name}| wc -l" + if [ $(eval ${count}) -gt 0 ]; then + pid="${name}| awk '{print \$2}'" + echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}" + #kill the service that existed + kill -9 $(eval $pid) + echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}" + fi + done +done \ No newline at end of file diff --git a/openim-chat/scripts/style_info.sh b/openim-chat/scripts/style_info.sh new file mode 100644 index 000000000..452240035 --- /dev/null +++ b/openim-chat/scripts/style_info.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +function style-info() { + COLOR_SUFFIX="\033[0m" # End all colors and special effects + + BLACK_PREFIX="\033[30m" # Black prefix + RED_PREFIX="\033[31m" # Red prefix + GREEN_PREFIX="\033[32m" # Green prefix + YELLOW_PREFIX="\033[33m" # Yellow prefix + BLUE_PREFIX="\033[34m" # Blue prefix + PURPLE_PREFIX="\033[35m" # Purple prefix + SKY_BLUE_PREFIX="\033[36m" # Sky blue prefix + WHITE_PREFIX="\033[37m" # White prefix + BOLD_PREFIX="\033[1m" # Bold prefix + UNDERLINE_PREFIX="\033[4m" # Underline prefix + ITALIC_PREFIX="\033[3m" # Italic prefix + + CYAN_PREFIX="033[0;36m" # Cyan prefix + + BACKGROUND_BLACK="\033[40m" # Black background + BACKGROUND_RED="\033[41m" # Red background + BACKGROUND_GREEN="\033[42m" # Green background + BACKGROUND_YELLOW="\033[43m" # Yellow background + BACKGROUND_BLUE="\033[44m" # Blue background + BACKGROUND_PURPLE="\033[45m" # Purple background + BACKGROUND_SKY_BLUE="\033[46m" # Sky blue background + BACKGROUND_WHITE="\033[47m" # White background + + BLINK="\033[5m" # Blinking effect + INVERT="\033[7m" # Invert color + HIDE="\033[8m" # Hide text + + GRAY_PREFIX="\033[90m" # Gray prefix + LIGHT_RED_PREFIX="\033[91m" # Light red prefix + LIGHT_GREEN_PREFIX="\033[92m" # Light green prefix + LIGHT_YELLOW_PREFIX="\033[93m" # Light yellow prefix + LIGHT_BLUE_PREFIX="\033[94m" # Light blue prefix + LIGHT_PURPLE_PREFIX="\033[95m" # Light purple prefix + LIGHT_SKY_BLUE_PREFIX="\033[96m" # Light sky blue prefix + LIGHT_WHITE_PREFIX="\033[97m" # Light white prefix + + BACKGROUND_GRAY="\033[100m" # Gray background + BACKGROUND_LIGHT_RED="\033[101m" # Light red background + BACKGROUND_LIGHT_GREEN="\033[102m" # Light green background + BACKGROUND_LIGHT_YELLOW="\033[103m" # Light yellow background + BACKGROUND_LIGHT_BLUE="\033[104m" # Light blue background + BACKGROUND_LIGHT_PURPLE="\033[105m" # Light purple background + BACKGROUND_LIGHT_SKY_BLUE="\033[106m" # Light sky blue background + BACKGROUND_LIGHT_WHITE="\033[107m" # Light white background +} + +style-info \ No newline at end of file diff --git a/scripts/docker_check_service.sh b/scripts/docker_check_service.sh index b08c2aa7c..e2224c8d9 100755 --- a/scripts/docker_check_service.sh +++ b/scripts/docker_check_service.sh @@ -17,6 +17,7 @@ # Include shell font styles and some basic information SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +Chat_Script=$SCRIPTS_ROOT/../openim-chat/scripts source "$SCRIPTS_ROOT/style_info.sh" @@ -94,6 +95,8 @@ do_sth() { kill "$_progress_pid" "$_countdown_pid" "${SCRIPTS_ROOT}/check_all.sh" + echo -e "${GREEN_PREFIX}=========> Check chat-compose status ${COLOR_SUFFIX} \n" + "${Chat_Script}/check_all.sh" echo -e "${PURPLE_PREFIX}=========> Check docker-compose status ${COLOR_SUFFIX} \n" } diff --git a/tools/component/main.go b/tools/component/main.go index 422afcbe1..c683ac383 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -29,7 +29,7 @@ import ( ) const ( - cfgPath = "../../../../../config/config.yaml" + cfgPath = "../../config/config.yaml" minioHealthCheckDuration = 1 maxRetry = 100 componentStartErrCode = 6000 @@ -142,12 +142,12 @@ func checkMysql() error { config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address[0], "mysql") db, err := gorm.Open(mysql.Open(dsn), nil) if err != nil { - return err + return errs.Wrap(err) } else { sqlDB, err = db.DB() err = sqlDB.Ping() if err != nil { - return err + return errs.Wrap(err) } } return nil @@ -172,11 +172,11 @@ func checkMongo() error { fmt.Sprintf("mongodb://%v:%v@%v/?authSource=admin", config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts))) if err != nil { - return err + return errs.Wrap(err) } else { err = client.Ping(context.TODO(), &readpref.ReadPref{}) if err != nil { - return err + return errs.Wrap(err) } } return nil @@ -191,7 +191,7 @@ func checkMinio() error { Secure: u.Scheme == "https", }) if err != nil { - return err + return errs.Wrap(err) } cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration) * time.Second) @@ -201,7 +201,7 @@ func checkMinio() error { } }() if err != nil { - return err + return errs.Wrap(err) } else { if minioClient.IsOffline() { return ErrComponentStart.Wrap("Minio server is offline") @@ -236,7 +236,7 @@ func checkRedis() error { } _, err := redisClient.Ping(context.Background()).Result() if err != nil { - return err + return errs.Wrap(err) } return nil } @@ -250,16 +250,16 @@ func checkZookeeper() error { }() c, _, err := zk.Connect(config.Config.Zookeeper.ZkAddr, time.Second) if err != nil { - return err + return errs.Wrap(err) } else { if config.Config.Zookeeper.Username != "" && config.Config.Zookeeper.Password != "" { if err := c.AddAuth("digest", []byte(config.Config.Zookeeper.Username+":"+config.Config.Zookeeper.Password)); err != nil { - return err + return errs.Wrap(err) } } _, _, err = c.Get("/") if err != nil { - return err + return errs.Wrap(err) } } return nil @@ -280,7 +280,7 @@ func checkKafka() error { } kafkaClient, err := sarama.NewClient(config.Config.Kafka.Addr, cfg) if err != nil { - return err + return errs.Wrap(err) } else { topics, err := kafkaClient.Topics() if err != nil { From 7994b377f73feae1b06deefbc202a7fdd2baa6d3 Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:16:41 +0800 Subject: [PATCH 10/12] fix: check component (#898) * fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * refactor: log change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * chore: network mode change Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add api of get server time Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * feat: remove go work sum Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: pull message add isRead field Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: check msg-transfer script Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: script update Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: start don't kill old process Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: check component Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> Co-authored-by: FGadvancer --- pkg/common/db/unrelation/msg.go | 3 ++- tools/component/main.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/common/db/unrelation/msg.go b/pkg/common/db/unrelation/msg.go index a1594ecc8..b48066349 100644 --- a/pkg/common/db/unrelation/msg.go +++ b/pkg/common/db/unrelation/msg.go @@ -19,9 +19,10 @@ import ( "encoding/json" "errors" "fmt" - "github.com/OpenIMSDK/tools/log" "time" + "github.com/OpenIMSDK/tools/log" + "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/constant" diff --git a/tools/component/main.go b/tools/component/main.go index c683ac383..db9ea915c 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -29,7 +29,7 @@ import ( ) const ( - cfgPath = "../../config/config.yaml" + cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 maxRetry = 100 componentStartErrCode = 6000 From 888351493a914e71e8211f6d65314232739f37b0 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com> Date: Sat, 19 Aug 2023 16:26:45 +0800 Subject: [PATCH 11/12] feat: add docker compose fix Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --- scripts/start_component_check.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/start_component_check.sh diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh old mode 100644 new mode 100755 From 7e8b975e229d870dba0fb48aba142cefc3da7b3a Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com> Date: Sat, 19 Aug 2023 16:26:49 +0800 Subject: [PATCH 12/12] feat: add docker compose fix Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --- scripts/check-all.sh | 52 ++++++++++++++++++++ scripts/install/install-protobuf.sh | 73 +++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100755 scripts/check-all.sh create mode 100644 scripts/install/install-protobuf.sh diff --git a/scripts/check-all.sh b/scripts/check-all.sh new file mode 100755 index 000000000..ea00db032 --- /dev/null +++ b/scripts/check-all.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script is check openim service is running normally +# +# Usage: `scripts/check-all.sh`. +# Encapsulated as: `make check`. +# READ: https://github.com/OpenIMSDK/Open-IM-Server/tree/main/scripts/install/environment.sh + +set -o errexit +set -o nounset +set -o pipefail + +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +source "${OPENIM_ROOT}/scripts/install/common.sh" + +OPENIM_VERBOSE=4 + +echo "++++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}" + +echo "++++ Check all dependent service ports" +echo "+ The port being checked: ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}" +openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]} + +if [[ $? -ne 0 ]]; then + openim::log::error_exit "The service does not start properly, please check the port, query variable definition!" + echo "+++ https://github.com/OpenIMSDK/Open-IM-Server/tree/main/scripts/install/environment.sh +++" +else + echo "++++ Check all dependent service ports successfully !" +fi + +echo "++++ Check all OpenIM service ports" +echo "+ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}" +openim::util::check_ports ${OPENIM_SERVER_PORT_LISTARIES[@]} +if [[ $? -ne 0 ]]; then + echo "+++ cat openim log file >>> ${LOG_FILE}" + openim::log::error_exit "The service does not start properly, please check the port, query variable definition!" +else + echo "++++ Check all openim service ports successfully !" +fi \ No newline at end of file diff --git a/scripts/install/install-protobuf.sh b/scripts/install/install-protobuf.sh new file mode 100644 index 000000000..a9a1ef7a0 --- /dev/null +++ b/scripts/install/install-protobuf.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +# -------------------------------------------------------------- +# OpenIM Protoc Tool v1.0.0 +# -------------------------------------------------------------- +# OpenIM has released its custom Protoc tool version v1.0.0. +# This tool is customized to meet the specific needs of OpenIM and resides in its separate repository. +# It can be downloaded from the following link: +# https://github.com/OpenIMSDK/Open-IM-Protoc/releases/tag/v1.0.0 +# +# Download link (Windows): https://github.com/OpenIMSDK/Open-IM-Protoc/releases/download/v1.0.0/windows.zip +# Download link (Linux): https://github.com/OpenIMSDK/Open-IM-Protoc/releases/download/v1.0.0/linux.zip +# +# Installation steps (taking Windows as an example): +# 1. Visit the above link and download the version suitable for Windows. +# 2. Extract the downloaded file. +# 3. Add the extracted tool to your PATH environment variable so that it can be run directly from the command line. +# +# Note: The specific installation and usage instructions may vary based on the tool's actual implementation. It's advised to refer to official documentation. +# -------------------------------------------------------------- + +function help_message { + echo "Usage: ./install-protobuf.sh [option]" + echo "Options:" + echo "-i, --install Install the OpenIM Protoc tool." + echo "-u, --uninstall Uninstall the OpenIM Protoc tool." + echo "-r, --reinstall Reinstall the OpenIM Protoc tool." + echo "-c, --check Check if the OpenIM Protoc tool is installed." + echo "-h, --help Display this help message." +} + +function install_protobuf { + echo "Installing OpenIM Protoc tool..." + # Logic for installation based on the OS + # e.g., download, unzip, and add to PATH +} + +function uninstall_protobuf { + echo "Uninstalling OpenIM Protoc tool..." + # Logic for uninstallation + # e.g., remove from PATH and delete files +} + +function reinstall_protobuf { + echo "Reinstalling OpenIM Protoc tool..." + uninstall_protobuf + install_protobuf +} + +function check_protobuf { + echo "Checking for OpenIM Protoc tool installation..." + # Logic to check if the tool is installed + # e.g., which protoc or checking PATH +} + +while [ "$1" != "" ]; do + case $1 in + -i | --install ) install_protobuf + ;; + -u | --uninstall ) uninstall_protobuf + ;; + -r | --reinstall ) reinstall_protobuf + ;; + -c | --check ) check_protobuf + ;; + -h | --help ) help_message + exit + ;; + * ) help_message + exit 1 + esac + shift +done \ No newline at end of file