remove timer and database init

pull/232/head
FG 3 years ago
parent b217fede87
commit 32b9820725

@ -1 +1 @@
Subproject commit b0897aa3abe719729c2ce099404f08806917bfe3
Subproject commit 588c9bb77b9bd89a9261964006568b8655233cb6

@ -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

@ -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)
// }
//
// }
//
//}
}

@ -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

@ -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/"

@ -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
Loading…
Cancel
Save