mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 14:29:19 +08:00
feat: Optimize openim scripts and standard output logs (#1866)
* feat: add component check func * fix: fix the outpu error * fix: fix the stderr outpu * fix: fix the component check func * fix: fix the error * fix: fix the output error * fix: del the disruptions code * fix the log output format * fix: fix the tools version * fix: fix the cycle detection * fix: fix the error * fix: fix the flag * fix: add mongo ping detection * fix: fix the tools pkg version * fix: del the err * feat: support openim readme docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim readme docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim readme docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: fix the minio nil error * fix: del the repeated wrap and add err print * fix: fix this bug scripts * Revert "Check" --------- Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> Co-authored-by: luhaoling <2198702716@qq.com>
This commit is contained in:
@@ -20,7 +20,6 @@ import (
|
||||
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
_ "go.uber.org/automaxprocs"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
|
||||
@@ -54,14 +54,15 @@ func NewMongo() (*Mongo, error) {
|
||||
defer cancel()
|
||||
mongoClient, err = mongo.Connect(ctx, options.Client().ApplyURI(uri))
|
||||
if err == nil {
|
||||
if err = mongoClient.Ping(ctx, nil); err != nil {
|
||||
return nil, errs.Wrap(err, uri)
|
||||
}
|
||||
return &Mongo{db: mongoClient}, nil
|
||||
}
|
||||
if shouldRetry(err) {
|
||||
fmt.Printf("Failed to connect to MongoDB, retrying: %s\n", err)
|
||||
time.Sleep(time.Second) // exponential backoff could be implemented here
|
||||
continue
|
||||
}
|
||||
return nil, errs.Wrap(err, uri)
|
||||
}
|
||||
return nil, errs.Wrap(err, uri)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func NewZookeeperDiscoveryRegister() (discoveryregistry.SvcDiscoveryRegistry, er
|
||||
openkeeper.WithLogger(log.NewZkLogger()),
|
||||
)
|
||||
if err != nil {
|
||||
uriFormat := "address:%s, username :%s, password :%s, schema:%s."
|
||||
uriFormat := "address:%s, username:%s, password:%s, schema:%s."
|
||||
errInfo := fmt.Sprintf(uriFormat,
|
||||
config.Config.Zookeeper.ZkAddr,
|
||||
config.Config.Zookeeper.Username,
|
||||
|
||||
@@ -17,7 +17,6 @@ package startrpc
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -28,6 +27,8 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@@ -96,7 +97,7 @@ func Start(
|
||||
|
||||
err = rpcFn(client, srv)
|
||||
if err != nil {
|
||||
return errs.Wrap(err)
|
||||
return err
|
||||
}
|
||||
err = client.Register(
|
||||
rpcRegisterName,
|
||||
@@ -116,7 +117,7 @@ func Start(
|
||||
// Create a HTTP server for prometheus.
|
||||
httpServer := &http.Server{Handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), Addr: fmt.Sprintf("0.0.0.0:%d", prometheusPort)}
|
||||
if err := httpServer.ListenAndServe(); err != nil {
|
||||
log.Fatal("Unable to start a http server.")
|
||||
log.Fatal("Unable to start a http server. ", err.Error(), "PrometheusPort:", prometheusPort)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user