pull/218/head
wenxu12345 3 years ago
parent 6efe13d142
commit 0232f52281

@ -11,7 +11,6 @@ import (
apiThird "Open_IM/internal/api/third"
"Open_IM/internal/api/user"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"flag"
@ -21,10 +20,11 @@ import (
"github.com/gin-gonic/gin"
//"syscall"
"Open_IM/pkg/common/constant"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
gin.SetMode(gin.ReleaseMode)
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
@ -136,7 +136,7 @@ func main() {
officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs)
}
apiThird.MinioInit()
log.NewPrivateLog(constant.LogFileName)
log.Info("", "MinioInit fin")
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
flag.Parse()
r.Run(":" + strconv.Itoa(*ginPort))

@ -2,18 +2,19 @@ package main
import (
"Open_IM/internal/demo/register"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"flag"
"io"
"os"
"strconv"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"github.com/gin-gonic/gin"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
gin.SetMode(gin.ReleaseMode)
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
@ -29,7 +30,7 @@ func main() {
authRouterGroup.POST("/login", register.Login)
authRouterGroup.POST("/reset_password", register.ResetPassword)
}
log.NewPrivateLog(constant.LogFileName)
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
flag.Parse()
r.Run(":" + strconv.Itoa(*ginPort))

@ -2,11 +2,14 @@ package main
import (
"Open_IM/internal/msg_gateway/gate"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag"
"sync"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
wsPort := flag.Int("ws_port", 17778, "ws listening port")
flag.Parse()

@ -2,12 +2,15 @@ package main
import (
"Open_IM/internal/msg_transfer/logic"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"sync"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
log.NewPrivateLog(constant.LogFileName)
logic.Init()
logic.Run()
wg.Wait()

@ -2,6 +2,8 @@ package main
import (
"Open_IM/internal/push/logic"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag"
"sync"
)
@ -11,6 +13,7 @@ func main() {
flag.Parse()
var wg sync.WaitGroup
wg.Add(1)
log.NewPrivateLog(constant.LogFileName)
logic.Init(*rpcPort)
logic.Run()
wg.Wait()

@ -2,10 +2,7 @@ package main
import (
"Open_IM/pkg/common/constant"
commonDB "Open_IM/pkg/common/db"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log"
"time"
)
func main() {
@ -40,27 +37,27 @@ func main() {
// 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)
}
}
}
//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)
// }
//
// }
//
//}
}

@ -15,10 +15,11 @@ var (
)
func MinioInit() {
log.NewInfo("", utils.GetSelfFuncName())
operationID := utils.OperationIDGenerator()
log.NewInfo(operationID, utils.GetSelfFuncName())
minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
return
}
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
@ -26,7 +27,7 @@ func MinioInit() {
Secure: false,
})
if err != nil {
log.NewError("", utils.GetSelfFuncName(), "init minio client failed", err.Error())
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
return
}
opt := minio.MakeBucketOptions{
@ -35,15 +36,15 @@ func MinioInit() {
}
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
if err != nil {
log.NewInfo("", utils.GetSelfFuncName(), err.Error())
log.NewInfo(operationID, utils.GetSelfFuncName(), err.Error())
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
if err == nil && exists {
log.NewInfo("", utils.GetSelfFuncName(), "We already own %s\n", config.Config.Credential.Minio.Bucket)
log.NewInfo(operationID, utils.GetSelfFuncName(), "We already own %s\n", config.Config.Credential.Minio.Bucket)
} else {
if err != nil {
log.NewError("", utils.GetSelfFuncName(), err.Error())
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
}
log.NewError("", utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
return
}
}
@ -53,5 +54,5 @@ func MinioInit() {
// log.NewError("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
// return
//}
log.NewInfo("", utils.GetSelfFuncName(), "minio create and set policy success")
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
}

@ -2,8 +2,7 @@ package gate
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/statistics"
"fmt"
"github.com/go-playground/validator/v10"
@ -21,7 +20,7 @@ var (
func Init(rpcPort, wsPort int) {
//log initialization
log.NewPrivateLog(constant.LogFileName)
rwLock = new(sync.RWMutex)
validate = validator.New()
statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 300)

@ -2,9 +2,8 @@ package logic
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/kafka"
"Open_IM/pkg/common/log"
)
var (
@ -14,7 +13,7 @@ var (
)
func Init() {
log.NewPrivateLog(constant.LogFileName)
persistentCH.Init()
historyCH.Init()
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)

@ -10,7 +10,6 @@ import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/kafka"
"Open_IM/pkg/common/log"
"Open_IM/pkg/statistics"
"fmt"
)
@ -24,7 +23,7 @@ var (
)
func Init(rpcPort int) {
log.NewPrivateLog(constant.LogFileName)
rpcServer.Init(rpcPort)
pushCh.Init()
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}

@ -2,8 +2,7 @@ package db
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
//"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"fmt"
"go.mongodb.org/mongo-driver/mongo/options"
@ -34,7 +33,7 @@ func key(dbAddress, dbName string) string {
}
func init() {
log.NewPrivateLog(constant.LogFileName)
//log.NewPrivateLog(constant.LogFileName)
//var mgoSession *mgo.Session
var mongoClient *mongo.Client
var err1 error
@ -54,15 +53,16 @@ func init() {
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
if err != nil {
log.NewError(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
fmt.Println(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
time.Sleep(time.Duration(30) * time.Second)
mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
if err1 != nil {
log.NewError(" mongo.Connect retry failed, panic", err.Error(), uri)
fmt.Println(" mongo.Connect retry failed, panic", err.Error(), uri)
panic(err1.Error())
}
}
log.NewInfo("0", utils.GetSelfFuncName(), "mongo driver client init success")
fmt.Println("0", utils.GetSelfFuncName(), "mongo driver client init success")
DB.mongoClient = mongoClient
//mgoDailInfo := &mgo.DialInfo{

Loading…
Cancel
Save