Merge remote-tracking branch 'origin/tuoyun' into tuoyun

pull/218/head
wenxu12345 3 years ago
commit ad4c9fcc83

@ -10,7 +10,6 @@ import (
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"strings" "strings"
"time"
) )
func TagSendMessage(operationID, sendID, recvID, content string, senderPlatformID int32) { func TagSendMessage(operationID, sendID, recvID, content string, senderPlatformID int32) {
@ -25,8 +24,8 @@ func TagSendMessage(operationID, sendID, recvID, content string, senderPlatformI
msgData.Content = []byte(content) msgData.Content = []byte(content)
msgData.Options = map[string]bool{} msgData.Options = map[string]bool{}
msgData.Options[constant.IsSenderConversationUpdate] = false msgData.Options[constant.IsSenderConversationUpdate] = false
msgData.SendTime = time.Now().Unix() msgData.CreateTime = utils.GetCurrentTimestampByMill()
msgData.CreateTime = time.Now().Unix() msgData.ClientMsgID = utils.GetMsgID(sendID)
msgData.SenderPlatformID = senderPlatformID msgData.SenderPlatformID = senderPlatformID
req.MsgData = &msgData req.MsgData = &msgData
req.OperationID = operationID req.OperationID = operationID

@ -2,7 +2,7 @@ package db
import ( import (
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"fmt" "fmt"
"sync" "sync"
"time" "time"
@ -24,13 +24,13 @@ func initMysqlDB() {
var err1 error var err1 error
db, err := gorm.Open("mysql", dsn) db, err := gorm.Open("mysql", dsn)
if err != nil { if err != nil {
log.NewError("0", "Open failed ", err.Error(), dsn) fmt.Println("0", "Open failed ", err.Error(), dsn)
} }
if err != nil { if err != nil {
time.Sleep(time.Duration(30) * time.Second) time.Sleep(time.Duration(30) * time.Second)
db, err1 = gorm.Open("mysql", dsn) db, err1 = gorm.Open("mysql", dsn)
if err1 != nil { if err1 != nil {
log.NewError("0", "Open failed ", err1.Error(), dsn) fmt.Println("0", "Open failed ", err1.Error(), dsn)
panic(err1.Error()) panic(err1.Error())
} }
} }
@ -39,7 +39,7 @@ func initMysqlDB() {
sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s default charset utf8 COLLATE utf8_general_ci;", config.Config.Mysql.DBDatabaseName) sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s default charset utf8 COLLATE utf8_general_ci;", config.Config.Mysql.DBDatabaseName)
err = db.Exec(sql).Error err = db.Exec(sql).Error
if err != nil { if err != nil {
log.NewError("0", "Exec failed ", err.Error(), sql) fmt.Println("0", "Exec failed ", err.Error(), sql)
panic(err.Error()) panic(err.Error())
} }
db.Close() db.Close()
@ -48,11 +48,11 @@ func initMysqlDB() {
config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName) config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName)
db, err = gorm.Open("mysql", dsn) db, err = gorm.Open("mysql", dsn)
if err != nil { if err != nil {
log.NewError("0", "Open failed ", err.Error(), dsn) fmt.Println("0", "Open failed ", err.Error(), dsn)
panic(err.Error()) panic(err.Error())
} }
log.NewInfo("open db ok ", dsn) fmt.Println("open db ok ", dsn)
db.AutoMigrate(&Friend{}, db.AutoMigrate(&Friend{},
&FriendRequest{}, &FriendRequest{},
&Group{}, &Group{},
@ -64,49 +64,49 @@ func initMysqlDB() {
db.Set("gorm:table_options", "collation=utf8_unicode_ci") db.Set("gorm:table_options", "collation=utf8_unicode_ci")
if !db.HasTable(&Friend{}) { if !db.HasTable(&Friend{}) {
log.NewInfo("CreateTable Friend") fmt.Println("CreateTable Friend")
db.CreateTable(&Friend{}) db.CreateTable(&Friend{})
} }
if !db.HasTable(&FriendRequest{}) { if !db.HasTable(&FriendRequest{}) {
log.NewInfo("CreateTable FriendRequest") fmt.Println("CreateTable FriendRequest")
db.CreateTable(&FriendRequest{}) db.CreateTable(&FriendRequest{})
} }
if !db.HasTable(&Group{}) { if !db.HasTable(&Group{}) {
log.NewInfo("CreateTable Group") fmt.Println("CreateTable Group")
db.CreateTable(&Group{}) db.CreateTable(&Group{})
} }
if !db.HasTable(&GroupMember{}) { if !db.HasTable(&GroupMember{}) {
log.NewInfo("CreateTable GroupMember") fmt.Println("CreateTable GroupMember")
db.CreateTable(&GroupMember{}) db.CreateTable(&GroupMember{})
} }
if !db.HasTable(&GroupRequest{}) { if !db.HasTable(&GroupRequest{}) {
log.NewInfo("CreateTable GroupRequest") fmt.Println("CreateTable GroupRequest")
db.CreateTable(&GroupRequest{}) db.CreateTable(&GroupRequest{})
} }
if !db.HasTable(&User{}) { if !db.HasTable(&User{}) {
log.NewInfo("CreateTable User") fmt.Println("CreateTable User")
db.CreateTable(&User{}) db.CreateTable(&User{})
} }
if !db.HasTable(&Black{}) { if !db.HasTable(&Black{}) {
log.NewInfo("CreateTable Black") fmt.Println("CreateTable Black")
db.CreateTable(&Black{}) db.CreateTable(&Black{})
} }
if !db.HasTable(&ChatLog{}) { if !db.HasTable(&ChatLog{}) {
log.NewInfo("CreateTable Black") fmt.Println("CreateTable Black")
db.CreateTable(&ChatLog{}) db.CreateTable(&ChatLog{})
} }
if !db.HasTable(&Register{}) { if !db.HasTable(&Register{}) {
log.NewInfo("CreateTable Black") fmt.Println("CreateTable Black")
db.CreateTable(&Register{}) db.CreateTable(&Register{})
} }
if !db.HasTable(&Conversation{}) { if !db.HasTable(&Conversation{}) {
log.NewInfo("CreateTable Black") fmt.Println("CreateTable Black")
db.CreateTable(&Conversation{}) db.CreateTable(&Conversation{})
} }

@ -32,6 +32,5 @@ for ((i = 0; i < ${#service_source_root[*]}; i++)); do
else else
echo -e "${GREEN_PREFIX}${service_names[$i]} successfully be built ${COLOR_SUFFIX}\n" echo -e "${GREEN_PREFIX}${service_names[$i]} successfully be built ${COLOR_SUFFIX}\n"
fi fi
done done
echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX}

@ -15,7 +15,14 @@ need_to_start_server_shell=(
#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started #fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started
sleep 10 sleep 10
time=`date +"%Y-%m-%d %H:%M:%S"`
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
for i in ${need_to_start_server_shell[*]}; do for i in ${need_to_start_server_shell[*]}; do
chmod +x $i chmod +x $i
./$i ./$i

@ -14,7 +14,7 @@ ws_ports=($ports_array)
if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX} echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX}
exit 0 exit -1
fi fi
#Check if the service exists #Check if the service exists

@ -11,8 +11,19 @@ need_to_start_server_shell=(
sdk_svr_start.sh sdk_svr_start.sh
demo_svr_start.sh demo_svr_start.sh
) )
time=`date +"%Y-%m-%d %H:%M:%S"`
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
for i in ${need_to_start_server_shell[*]}; do for i in ${need_to_start_server_shell[*]}; do
chmod +x $i chmod +x $i
./$i ./$i
if [ $? -ne 0 ]; then
exit -1
fi
done done

@ -45,24 +45,23 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
if [ $(eval ${count}) -gt 0 ]; then if [ $(eval ${count}) -gt 0 ]; then
pid="${service_name}| awk '{print \$2}'" pid="${service_name}| awk '{print \$2}'"
echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX" echo "${service_filename[$i]} service has been started,pid:$(eval $pid)"
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}" echo "killing the service ${service_filename[$i]} pid:$(eval $pid)"
#kill the service that existed #kill the service that existed
kill -9 $(eval $pid) kill -9 $(eval $pid)
sleep 0.5 sleep 0.5
fi fi
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}" cd ../bin
#Get the rpc port in the configuration file #Get the rpc port in the configuration file
portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}') portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}')
list_to_string ${portList} list_to_string ${portList}
#Start related rpc services based on the number of ports #Start related rpc services based on the number of ports
for j in ${ports_array}; do for j in ${ports_array}; do
echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX"
#Start the service in the background #Start the service in the background
# ./${service_filename[$i]} -port $j & # ./${service_filename[$i]} -port $j &
nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 &
sleep 1 sleep 1
pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:$j pid:$(eval $pid)$COLOR_SUFFIX"
done done
done done
Loading…
Cancel
Save