Skip to content

Commit

Permalink
feat: fix openim ci and deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong(cubxxw) <[email protected]>
  • Loading branch information
cubxxw committed Oct 19, 2023
1 parent 7e63800 commit 035afff
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 756 deletions.
7 changes: 0 additions & 7 deletions build/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion build/images/openim-cmdutils/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN go mod download
COPY . .

RUN make build BINS=openim-cmdutils
RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-cmdutils /usr/bin/openim-api
RUN cp /openim/openim-server/_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-cmdutils /usr/bin/openim-cmdutils

FROM ghcr.io/openim-sigs/openim-bash-image:latest

Expand Down
40 changes: 22 additions & 18 deletions cmd/openim-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,73 +17,77 @@ package main
import (
"context"
"fmt"
"github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
"net"
_ "net/http/pprof"
"strconv"

"github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"

"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/log"

"github.com/openimsdk/open-im-server/v3/internal/api"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
)

var logger log.Logger // Assuming Logger is globally accessible and properly initialized

func main() {
apiCmd := cmd.NewApiCmd()
apiCmd.AddPortFlag()
apiCmd.AddApi(run)
if err := apiCmd.Execute(); err != nil {
logger.Error(context.Background(), "API command execution failed", err)
panic(err.Error())
}
}

func run(port int) error {
fmt.Println("*****openimapi port:", port)
logger.Info(context.Background(), "Openim api port:", "port", port)

if port == 0 {
return fmt.Errorf("port is empty")
err := "port is empty"
logger.Error(context.Background(), err, nil)
return fmt.Errorf(err)
}
rdb, err := cache.NewRedis()
if err != nil {
logger.Error(context.Background(), "Failed to initialize Redis", err)
return err
}
fmt.Println("api start init discov client")
logger.Info(context.Background(), "api start init discov client")

var client discoveryregistry.SvcDiscoveryRegistry
client, err = discovery_register.NewDiscoveryRegister(config.Config.Envs.Discovery)
/*
client, err = openkeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
openkeeper.WithFreq(time.Hour), openkeeper.WithUserNameAndPassword(
config.Config.Zookeeper.Username,
config.Config.Zookeeper.Password,
), openkeeper.WithRoundRobin(), openkeeper.WithTimeout(10), openkeeper.WithLogger(log.NewZkLogger()))*/
if err != nil {
logger.Error(context.Background(), "Failed to initialize discovery register", err)
return err
}
if err = client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil {
logger.Error(context.Background(), "Failed to create RPC root nodes", err)
return err
}
fmt.Println("api register public config to discov")
logger.Info(context.Background(), "api register public config to discov")
if err = client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil {
logger.Error(context.Background(), "Failed to register public config to discov", err)
return err
}
fmt.Println("api register public config to discov success")
logger.Info(context.Background(), "api register public config to discov success")
router := api.NewGinRouter(client, rdb)
fmt.Println("api init router success")
logger.Info(context.Background(), "api init router success")
var address string
if config.Config.Api.ListenIP != "" {
address = net.JoinHostPort(config.Config.Api.ListenIP, strconv.Itoa(port))
} else {
address = net.JoinHostPort("0.0.0.0", strconv.Itoa(port))
}
fmt.Println("start api server, address: ", address, ", OpenIM version: ", config.Version)
log.ZInfo(context.Background(), "start server success", "address", address, "version", config.Version)
logger.Info(context.Background(), "start api server", "address", address, "OpenIM version", config.Version)

err = router.Run(address)
if err != nil {
log.ZError(context.Background(), "api run failed ", err, "address", address)

logger.Error(context.Background(), "api run failed", err, "address", address)
return err
}

Expand Down
10 changes: 6 additions & 4 deletions deployments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ $ sudo sealos run labring/kubernetes:v1.25.0 labring/helm:v3.8.2 labring/calico:
-p "$CLUSTER_PASSWORD"
```

> **Node**
> 卸载的方式:使用 `kubeadm` 卸载并不会清除 `etcd``cni` 相关,所以需要手动清除,或者使用 `sealos` 卸载。
> ```bash
> sealos reset
> ```
### 安装 helm
helm通过打包的方式,支持发布的版本管理和控制,很大程度上简化了Kubernetes应用的部署和管理。
Expand All @@ -101,7 +107,3 @@ $ helm repo add brigade https://openimsdk.github.io/openim-charts
### 容器化安装

具体安装步骤如下:



### Helm安装
23 changes: 0 additions & 23 deletions deployments/openim-chat/.helmignore

This file was deleted.

38 changes: 0 additions & 38 deletions deployments/openim-chat/Chart.yaml

This file was deleted.

201 changes: 0 additions & 201 deletions deployments/openim-chat/LICENSE

This file was deleted.

Loading

0 comments on commit 035afff

Please sign in to comment.