mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
commit
2fd85660e5
@ -43,7 +43,8 @@ func main() {
|
||||
apiCmd.AddPortFlag()
|
||||
apiCmd.AddApi(run)
|
||||
if err := apiCmd.Execute(); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -54,6 +56,7 @@ func main() {
|
||||
// openIM clear msg --clearAll
|
||||
msgUtilsCmd.AddCommand(&getCmd.Command, &fixCmd.Command, &clearCmd.Command)
|
||||
if err := msgUtilsCmd.Execute(); err != nil {
|
||||
panic(err)
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,13 +15,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/internal/tools"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cronTaskCmd := cmd.NewCronTaskCmd()
|
||||
if err := cronTaskCmd.Exec(tools.StartTask); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -25,6 +27,7 @@ func main() {
|
||||
msgGatewayCmd.AddPrometheusPortFlag()
|
||||
|
||||
if err := msgGatewayCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -23,6 +25,7 @@ func main() {
|
||||
msgTransferCmd.AddPrometheusPortFlag()
|
||||
msgTransferCmd.AddTransferProgressFlag()
|
||||
if err := msgTransferCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,9 +15,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/internal/push"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -28,6 +30,7 @@ func main() {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := pushCmd.StartSvr(config.Config.RpcRegisterName.OpenImPushName, push.Start); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,9 +15,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/auth"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -28,6 +30,7 @@ func main() {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := authCmd.StartSvr(config.Config.RpcRegisterName.OpenImAuthName, auth.Start); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,9 +15,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/conversation"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -28,6 +30,7 @@ func main() {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImConversationName, conversation.Start); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,9 +15,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/friend"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -28,6 +30,7 @@ func main() {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImFriendName, friend.Start); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,9 +15,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/group"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -28,6 +30,7 @@ func main() {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImGroupName, group.Start); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,9 +15,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/msg"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -28,6 +30,7 @@ func main() {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImMsgName, msg.Start); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,9 +15,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/third"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -28,6 +30,7 @@ func main() {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImThirdName, third.Start); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,9 +15,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/user"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -28,6 +30,7 @@ func main() {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImUserName, user.Start); err != nil {
|
||||
panic(err.Error())
|
||||
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.19
|
||||
require (
|
||||
firebase.google.com/go v3.13.0+incompatible
|
||||
github.com/OpenIMSDK/protocol v0.0.48
|
||||
github.com/OpenIMSDK/tools v0.0.32
|
||||
github.com/OpenIMSDK/tools v0.0.33
|
||||
github.com/bwmarrin/snowflake v0.3.0 // indirect
|
||||
github.com/dtm-labs/rockscache v0.1.1
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
|
||||
4
go.sum
4
go.sum
@ -20,8 +20,8 @@ github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c=
|
||||
github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ=
|
||||
github.com/OpenIMSDK/protocol v0.0.48 h1:8MIMjyzJRsruYhVv2ZKArFiOveroaofDOb3dlAdgjsw=
|
||||
github.com/OpenIMSDK/protocol v0.0.48/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||
github.com/OpenIMSDK/tools v0.0.32 h1:b8KwtxXKZTsyyHUcZ4OtSo6s/vVXx4HjMuPxH7Kb7Gg=
|
||||
github.com/OpenIMSDK/tools v0.0.32/go.mod h1:wBfR5CYmEyvxl03QJbTkhz1CluK6J4/lX0lviu8JAjE=
|
||||
github.com/OpenIMSDK/tools v0.0.33 h1:rvFCxXaXxLv1MJFC4qcoWRGwKBnV+hR68UN2N0/zZhE=
|
||||
github.com/OpenIMSDK/tools v0.0.33/go.mod h1:wBfR5CYmEyvxl03QJbTkhz1CluK6J4/lX0lviu8JAjE=
|
||||
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
|
||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
|
||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -97,7 +97,7 @@ func Start(
|
||||
|
||||
err = rpcFn(client, srv)
|
||||
if err != nil {
|
||||
return errs.Wrap(err)
|
||||
return err
|
||||
}
|
||||
err = client.Register(
|
||||
rpcRegisterName,
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/IBM/sarama"
|
||||
@ -56,6 +57,7 @@ func initCfg() error {
|
||||
type checkFunc struct {
|
||||
name string
|
||||
function func() error
|
||||
flag bool
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -86,13 +88,17 @@ func main() {
|
||||
|
||||
var err error
|
||||
allSuccess := true
|
||||
for _, check := range checks {
|
||||
err = check.function()
|
||||
if err != nil {
|
||||
component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, err))
|
||||
allSuccess = false
|
||||
} else {
|
||||
component.SuccessPrint(fmt.Sprintf("%s connected successfully", check.name))
|
||||
for index, check := range checks {
|
||||
if !check.flag {
|
||||
err = check.function()
|
||||
if err != nil {
|
||||
component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, err))
|
||||
allSuccess = false
|
||||
|
||||
} else {
|
||||
checks[index].flag = true
|
||||
component.SuccessPrint(fmt.Sprintf("%s connected successfully", check.name))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,7 +126,7 @@ func checkMinio() error {
|
||||
|
||||
// Check if MinIO is enabled
|
||||
if config.Config.Object.Enable != "minio" {
|
||||
return nil
|
||||
return errs.Wrap(errors.New("minio.Enable is empty"))
|
||||
}
|
||||
minio := &component.Minio{
|
||||
ApiURL: config.Config.Object.ApiURL,
|
||||
@ -130,7 +136,7 @@ func checkMinio() error {
|
||||
SignEndpoint: config.Config.Object.Minio.SignEndpoint,
|
||||
UseSSL: getEnv("MINIO_USE_SSL", "false"),
|
||||
}
|
||||
_, err := component.CheckMinio(minio)
|
||||
err := component.CheckMinio(minio)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -149,7 +155,7 @@ func checkKafka() error {
|
||||
Addr: config.Config.Kafka.Addr,
|
||||
}
|
||||
|
||||
_, kafkaClient, err := component.CheckKafka(kafkaStu)
|
||||
kafkaClient, err := component.CheckKafka(kafkaStu)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user