mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-02 18:34:29 +08:00
fix: fix the cycle detection
This commit is contained in:
parent
633388b6d8
commit
7a8597fa85
@ -57,7 +57,6 @@ func NewMongo() (*Mongo, error) {
|
|||||||
return &Mongo{db: mongoClient}, nil
|
return &Mongo{db: mongoClient}, nil
|
||||||
}
|
}
|
||||||
if shouldRetry(err) {
|
if shouldRetry(err) {
|
||||||
fmt.Printf("Failed to connect to MongoDB, retrying: %s\n", err)
|
|
||||||
time.Sleep(time.Second) // exponential backoff could be implemented here
|
time.Sleep(time.Second) // exponential backoff could be implemented here
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,7 @@ func initCfg() error {
|
|||||||
type checkFunc struct {
|
type checkFunc struct {
|
||||||
name string
|
name string
|
||||||
function func() error
|
function func() error
|
||||||
|
flag bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -87,11 +88,15 @@ func main() {
|
|||||||
var err error
|
var err error
|
||||||
allSuccess := true
|
allSuccess := true
|
||||||
for _, check := range checks {
|
for _, check := range checks {
|
||||||
err = check.function()
|
if !check.flag {
|
||||||
|
err = check.function()
|
||||||
|
continue
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, err))
|
component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, err))
|
||||||
allSuccess = false
|
allSuccess = false
|
||||||
} else {
|
} else {
|
||||||
|
check.flag = true
|
||||||
component.SuccessPrint(fmt.Sprintf("%s connected successfully", check.name))
|
component.SuccessPrint(fmt.Sprintf("%s connected successfully", check.name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user