@ -2,6 +2,7 @@ package db
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"fmt"
@ -33,6 +34,7 @@ func key(dbAddress, dbName string) string {
}
func init ( ) {
log . NewPrivateLog ( constant . LogFileName )
//var mgoSession *mgo.Session
var mongoClient * mongo . Client
var err1 error
@ -51,7 +53,7 @@ func init() {
}
mongoClient , err := mongo . Connect ( context . TODO ( ) , options . Client ( ) . ApplyURI ( uri ) )
if err != nil {
if err != nil {
log . NewError ( " 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 ) )