From 32b982072525ca529ed99999f165964cf1b4a246 Mon Sep 17 00:00:00 2001 From: FG <1432970085@qq.com> Date: Sat, 7 May 2022 10:37:52 +0800 Subject: [PATCH] remove timer and database init --- cmd/Open-IM-SDK-Core | 2 +- cmd/open_im_timer_task/Makefile | 25 ------------- cmd/open_im_timer_task/main.go | 63 --------------------------------- script/mysql_database_init.sh | 38 -------------------- script/path_info.cfg | 4 --- script/timer_start.sh | 35 ------------------ 6 files changed, 1 insertion(+), 166 deletions(-) delete mode 100644 cmd/open_im_timer_task/Makefile delete mode 100644 cmd/open_im_timer_task/main.go delete mode 100644 script/mysql_database_init.sh delete mode 100644 script/timer_start.sh diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index b0897aa3a..588c9bb77 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit b0897aa3abe719729c2ce099404f08806917bfe3 +Subproject commit 588c9bb77b9bd89a9261964006568b8655233cb6 diff --git a/cmd/open_im_timer_task/Makefile b/cmd/open_im_timer_task/Makefile deleted file mode 100644 index 6c6d713d8..000000000 --- a/cmd/open_im_timer_task/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -.PHONY: all build run gotool install clean help - -BINARY_NAME=open_im_timer_task -BIN_DIR=../../bin/ - -all: gotool build - -build: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" - -run: - @go run ./ - -gotool: - go fmt ./ - go vet ./ - -install: - make build - mv ${BINARY_NAME} ${BIN_DIR} - -clean: - @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi - - diff --git a/cmd/open_im_timer_task/main.go b/cmd/open_im_timer_task/main.go deleted file mode 100644 index 20d9a4d1c..000000000 --- a/cmd/open_im_timer_task/main.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" -) - -func main() { - log.NewPrivateLog(constant.LogFileName) - //for { - // fmt.Println("start delete mongodb expired record") - // timeUnixBegin := time.Now().Unix() - // count, _ := db.DB.MgoUserCount() - // fmt.Println("mongodb record count: ", count) - // for i := 0; i < count; i++ { - // time.Sleep(1 * time.Millisecond) - // uid, _ := db.DB.MgoSkipUID(i) - // fmt.Println("operate uid: ", uid) - // err := db.DB.DelUserChat(uid) - // if err != nil { - // fmt.Println("operate uid failed: ", uid, err.Error()) - // } - // } - // - // timeUnixEnd := time.Now().Unix() - // costTime := timeUnixEnd - timeUnixBegin - // if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) { - // continue - // } else { - // sleepTime := 0 - // if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 { - // sleepTime = 24 * 3600 - // } else { - // sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime) - // } - // fmt.Println("sleep: ", sleepTime) - // time.Sleep(time.Duration(sleepTime) * time.Second) - // } - //} - //for { - // uidList, err := im_mysql_model.SelectAllUserID() - // if err != nil { - // //log.NewError("999999", err.Error()) - // } else { - // for _, v := range uidList { - // minSeq, err := commonDB.DB.GetMinSeqFromMongo(v) - // if err != nil { - // //log.NewError("999999", "get user minSeq err", err.Error(), v) - // continue - // } else { - // err := commonDB.DB.SetUserMinSeq(v, minSeq) - // if err != nil { - // //log.NewError("999999", "set user minSeq err", err.Error(), v) - // } - // } - // time.Sleep(time.Duration(100) * time.Millisecond) - // } - // - // } - // - //} - -} diff --git a/script/mysql_database_init.sh b/script/mysql_database_init.sh deleted file mode 100644 index 2a5135e8e..000000000 --- a/script/mysql_database_init.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -#define database attributes -address=$(cat $config_path | grep -w dbMysqlAddress) -list_to_string ${address} -hostAndPort=($ports_array) -DATABASE_HOST=$(echo $hostAndPort | awk -F '[:]' '{print $1}') -DATABASE_PORT=$(echo $hostAndPort | awk -F '[:]' '{print $NF}') -DATABASE_USERNAME=$(cat $config_path | grep -w dbMysqlUserName | awk -F '[:]' '{print $NF}') -DATABASE_PWD=`eval echo $(cat $config_path | grep -w dbMysqlPassword | awk -F '[:]' '{print $NF}')` -DATABASE_NAME=$(cat $config_path | grep -w dbMysqlDatabaseName | awk -F '[:]' '{print $NF}') -SQL_FILE="../config/mysql_sql_file/openIM.sql" - - -create_data_sql="create database IF NOT EXISTS $DATABASE_NAME" -set_character_code_sql="alter database $DATABASE_NAME character set utf8mb4 collate utf8mb4_general_ci" - -echo -e "${SKY_BLUE_PREFIX}start to create database.....$COLOR_SUFFIX" -mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$create_data_sql" - -if [ $? -eq 0 ]; then - echo -e "${SKY_BLUE_PREFIX}create database ${DATABASE_NAME} successfully$COLOR_SUFFIX" - mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$set_character_code_sql" -else - echo -e "${RED_PREFIX}create database failed or exists the database$COLOR_SUFFIX\n" -fi - -echo -e "${SKY_BLUE_PREFIX}start to source openIM.sql .....$COLOR_SUFFIX" -mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -D $DATABASE_NAME <$SQL_FILE -if [ $? -eq 0 ]; then - echo -e "${SKY_BLUE_PREFIX}source openIM.sql successfully$COLOR_SUFFIX" -else - echo -e "${RED_PREFIX}source openIM.sql failed$COLOR_SUFFIX\n" -fi diff --git a/script/path_info.cfg b/script/path_info.cfg index 9c9b0c264..0a47f51fd 100644 --- a/script/path_info.cfg +++ b/script/path_info.cfg @@ -19,10 +19,6 @@ msg_transfer_source_root="../cmd/open_im_msg_transfer/" msg_transfer_service_num=2 -timer_task_name="open_im_timer_task" -timer_task_binary_root="../bin/" -timer_task_source_root="../cmd/open_im_timer_task/" - sdk_server_name="open_im_sdk_server" sdk_server_binary_root="../bin/" sdk_server_source_root="../cmd/Open-IM-SDK-Core/" diff --git a/script/timer_start.sh b/script/timer_start.sh deleted file mode 100644 index 7e2791f11..000000000 --- a/script/timer_start.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg - - - -#Check if the service exists -#If it is exists,kill this process -check=`ps aux | grep -w ./${timer_task_name} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -oldPid=`ps aux | grep -w ./${timer_task_name} | grep -v grep|awk '{print $2}'` - kill -9 $oldPid -fi -#Waiting port recycling -sleep 1 - -cd ${timer_task_binary_root} -nohup ./${timer_task_name} >>../logs/openIM.log 2>&1 & - - -#Check launched service process -check=`ps aux | grep -w ./${timer_task_name} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -newPid=`ps aux | grep -w ./${timer_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}${YELLOW_PREFIX}${timer_task_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}${timer_task_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi