diff --git a/.env b/.env
index 4f684ad77..bcfc0722a 100644
--- a/.env
+++ b/.env
@@ -30,12 +30,19 @@ MINIO_ENDPOINT=http://172.28.0.1:10005
# Base URL for the application programming interface (API).
# Default: API_URL=http://172.28.0.1:10002
-API_URL=http://127.0.0.1:10002
+API_URL=http://172.28.0.1:10002
# Directory path for storing data files or related information.
# Default: DATA_DIR=./
DATA_DIR=./
+# Choose the appropriate image address, the default is GITHUB image,
+# you can choose docker hub, for Chinese users can choose Ali Cloud
+# export IMAGE_REGISTRY="ghcr.io/openimsdk"
+# export IMAGE_REGISTRY="openim"
+# export IMAGE_REGISTRY="registry.cn-hangzhou.aliyuncs.com/openimsdk"
+IMAGE_REGISTRY=ghcr.io/openimsdk
+
# ======================================
# ========= Network Configuration ======
# ======================================
diff --git a/.github/workflows/docker-buildx.yml b/.github/workflows/docker-buildx.yml
index 366317b1c..6113cfae5 100644
--- a/.github/workflows/docker-buildx.yml
+++ b/.github/workflows/docker-buildx.yml
@@ -54,6 +54,19 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Log in to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+
+ - name: Log in to AliYun Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: registry.cn-hangzhou.aliyuncs.com
+ username: ${{ secrets.ALIREGISTRY_USERNAME }}
+ password: ${{ secrets.ALIREGISTRY_TOKEN }}
+
################################################
# build/
# └── docker
@@ -89,7 +102,10 @@ jobs:
id: meta1
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-api
+ images: |
+ ghcr.io/openimsdk/openim-api
+ openim/openim-api
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-api
- name: Build and push Docker image for openim-api
uses: docker/build-push-action@v5
@@ -107,7 +123,10 @@ jobs:
id: meta2
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-cmdutils
+ images: |
+ ghcr.io/openimsdk/openim-cmdutils
+ openim/openim-cmdutils
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-cmdutils
- name: Build and push Docker image for openim-cmdutils
uses: docker/build-push-action@v5
@@ -125,7 +144,10 @@ jobs:
id: meta3
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-crontask
+ images: |
+ ghcr.io/openimsdk/openim-crontask
+ openim/openim-crontask
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-crontask
- name: Build and push Docker image for openim-crontask
uses: docker/build-push-action@v5
@@ -143,7 +165,10 @@ jobs:
id: meta4
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-msggateway
+ images: |
+ ghcr.io/openimsdk/openim-msggateway
+ openim/openim-msggateway
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-msggateway
- name: Build and push Docker image for openim-msggateway
uses: docker/build-push-action@v5
@@ -161,7 +186,10 @@ jobs:
id: meta5
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-msgtransfer
+ images: |
+ ghcr.io/openimsdk/openim-msgtransfer
+ openim/openim-msgtransfer
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-msgtransfer
- name: Build and push Docker image for openim-msgtransfer
uses: docker/build-push-action@v5
@@ -179,7 +207,10 @@ jobs:
id: meta6
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-push
+ images: |
+ ghcr.io/openimsdk/openim-push
+ openim/openim-push
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-push
- name: Build and push Docker image for openim-push
uses: docker/build-push-action@v5
@@ -197,7 +228,10 @@ jobs:
id: meta7
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-auth
+ images: |
+ ghcr.io/openimsdk/openim-rpc-auth
+ openim/openim-rpc-auth
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-auth
- name: Build and push Docker image for openim-rpc-auth
uses: docker/build-push-action@v5
@@ -215,7 +249,10 @@ jobs:
id: meta8
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-conversation
+ images: |
+ ghcr.io/openimsdk/openim-rpc-conversation
+ openim/openim-rpc-conversation
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-conversation
- name: Build and push Docker image for openim-rpc-conversation
uses: docker/build-push-action@v5
@@ -233,7 +270,10 @@ jobs:
id: meta9
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-friend
+ images: |
+ ghcr.io/openimsdk/openim-rpc-friend
+ openim/openim-rpc-friend
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-friend
- name: Build and push Docker image for openim-rpc-friend
uses: docker/build-push-action@v5
@@ -251,7 +291,10 @@ jobs:
id: meta10
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-group
+ images: |
+ ghcr.io/openimsdk/openim-rpc-group
+ openim/openim-rpc-group
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-group
- name: Build and push Docker image for openim-rpc-group
uses: docker/build-push-action@v5
@@ -269,7 +312,10 @@ jobs:
id: meta11
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-msg
+ images: |
+ ghcr.io/openimsdk/openim-rpc-msg
+ openim/openim-rpc-msg
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-msg
- name: Build and push Docker image for openim-rpc-msg
uses: docker/build-push-action@v5
@@ -287,7 +333,10 @@ jobs:
id: meta12
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-third
+ images: |
+ ghcr.io/openimsdk/openim-rpc-third
+ openim/openim-rpc-third
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-third
- name: Build and push Docker image for openim-rpc-third
uses: docker/build-push-action@v5
@@ -305,7 +354,10 @@ jobs:
id: meta13
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-user
+ images: |
+ ghcr.io/openimsdk/openim-rpc-user
+ openim/openim-rpc-user
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-user
- name: Build and push Docker image for openim-rpc-user
uses: docker/build-push-action@v5
@@ -318,4 +370,3 @@ jobs:
labels: ${{ steps.meta13.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
-
diff --git a/.github/workflows/opencommit.yml b/.github/workflows/opencommit.yml
index db244705c..6496bd2ce 100644
--- a/.github/workflows/opencommit.yml
+++ b/.github/workflows/opencommit.yml
@@ -27,7 +27,7 @@ jobs:
permissions: write-all
steps:
- name: Setup Node.js Environment
- uses: actions/setup-node@v3
+ uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/checkout@v4
diff --git a/.github/workflows/openimci.yml b/.github/workflows/openimci.yml
index 347f6d762..05a8ce5c5 100644
--- a/.github/workflows/openimci.yml
+++ b/.github/workflows/openimci.yml
@@ -170,3 +170,24 @@ jobs:
- name: Print OpenIM Logs
run: sudo cat ./_output/logs/* 2>/dev/null
continue-on-error: true
+
+ openim-build-image:
+ name: Build OpenIM Docker Image
+ runs-on: ubuntu-latest
+ environment:
+ name: openim
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ - name: Set up Go ${{ matrix.go_version }}
+ uses: actions/setup-go@v4
+ with:
+ go-version: ${{ matrix.go_version }}
+ id: go
+ - name: Install Task
+ uses: arduino/setup-task@v1
+ with:
+ version: 2.x
+ - name: Test Docker Build
+ run: |
+ sudo make image
\ No newline at end of file
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
index 8094718c6..045f269d6 100644
--- a/.github/workflows/pull-request.yml
+++ b/.github/workflows/pull-request.yml
@@ -42,7 +42,7 @@ jobs:
git config user.name 'openimbot'
git config user.email 'openimsdk@qq.com'
git checkout -b cicd/patch-${{ github.event.number }}
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
- name: Setup Go
uses: actions/setup-go@v4
- name: Run go modules tidy
diff --git a/.gitignore b/.gitignore
index 92408fa56..fa1818e2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,6 +29,7 @@ tmp/
bin/
output/
_output/
+deployments/charts/generated-configs/
### OpenIM Config ###
config/config.yaml
@@ -37,18 +38,7 @@ config/config.yaml
./.env
### OpenIM deploy ###
-deploy/openim_demo
-deploy/openim-api
-deploy/openim-rpc-msg_gateway
-deploy/openim-msgtransfer
-deploy/openim-push
-deploy/openim_timer_task
-deploy/openim-rpc-user
-deploy/openim-rpc-friend
-deploy/openim-rpc-group
-deploy/openim-rpc-msg
-deploy/openim-rpc-auth
-deploy/Open-IM-SDK-Core
+deployments/openim-server/charts
# files used by the developer
.idea.md
diff --git a/.golangci.yml b/.golangci.yml
index dd68ce5a6..b129ffd68 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -715,83 +715,18 @@ linters:
# enable-all: true
disable-all: true
enable:
- - typecheck
- - asciicheck
- - bodyclose
- - cyclop
- # - depguard
- - dogsled
- - dupl
- - durationcheck
- - errcheck
- - errorlint
- - exhaustive
- - exportloopref
- # - forbidigo
- - funlen
- # - gci
- # - gochecknoinits
- - gocognit
- - goconst
- - gocyclo
- - godot
- - godox
- - gofmt
- - gofumpt
- - goheader
- - goimports
- - gomoddirectives
- - gomodguard
- - goprintffuncname
- - gosec
- - gosimple
- - govet
- - importas
- - ineffassign
- - lll
- - makezero
- - misspell
- - nakedret
- - nestif
- - nilerr
- - nlreturn
- - noctx
- - nolintlint
- - paralleltest
- - prealloc
- - predeclared
- - promlinter
- - revive
- - rowserrcheck
- - sqlclosecheck
- - staticcheck
- - stylecheck
- - thelper
- - tparallel
- - unconvert
- - unparam
- - unused
- - wastedassign
- - whitespace
- - bidichk
- - wastedassign
- - execinquery
- - nosprintfhostport
- - grouper
- - decorder
- - errchkjson
- - maintidx
- #- containedctx
- #- tagliatelle
- #- nonamedreturns
- #- nilnil
- #- tenv
- #- varnamelen
- #- contextcheck
- #- errname
- #- ForceTypeAssert
- #- nilassign
- fast: false
+ - typecheck # 基本的类型检查
+ - gofmt # 格式检查
+ - govet # Go 语言的标准检查工具
+ - gosimple # 简化代码的建议
+ - misspell # 拼写错误
+ - staticcheck # 静态检查
+ - unused # 未使用的代码检查
+ - goimports # 检查导入是否正确排序和格式化
+ - godot # 注释句点检查
+ - bodyclose # 确保 HTTP response body 被关闭
+ - errcheck # 检查是否遗漏了错误返回值
+ fast: true
issues:
# List of regexps of issue texts to exclude, empty list by default.
diff --git a/Makefile b/Makefile
index 1d01409a5..67f595fb4 100644
--- a/Makefile
+++ b/Makefile
@@ -73,9 +73,9 @@ gen:
demo:
@$(MAKE) go.demo
-## versionchecker: Check version of openim. ✨
-.PHONY: versionchecker
-versionchecker:
+## version: Check version of openim. ✨
+.PHONY: version
+version:
@$(MAKE) go.versionchecker
## build: Build binaries by default ✨
@@ -93,9 +93,9 @@ start:
stop:
@$(MAKE) go.stop
-## restart: Restart openim ✨
+## restart: Restart openim (make init configuration file is initialized) ✨
.PHONY: restart
-restart: clean stop build init start
+restart: clean stop build init start check
## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨
.PHONY: multiarch
diff --git a/README-zh_CN.md b/README-zh_CN.md
index 8addfe20a..f24ee4739 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -1,5 +1,5 @@
-
+
@@ -23,7 +23,7 @@
English •
简体中文 •
- Docs
+ Docs
diff --git a/README.md b/README.md
index f58625fb0..0a569af6e 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
+
@@ -24,7 +24,7 @@
English •
简体中文 •
- Docs
+ Docs
@@ -61,7 +61,7 @@ It's crafted in Golang and supports cross-platform deployment, ensuring a cohere
+ **REST API**: OpenIMServer provides REST API for business systems, aiming to empower your operations with additional functionalities like group creation and message push via backend interfaces.
+ **Callbacks**: To expand its utility across varied business forms, OpenIMServer offers callback capabilities. That is, it sends a request to the business server before or after an event occurs, such as sending a message, enriching the interaction and data exchange flow in the communication processes.
-👉 **[Learn More](https://doc.rentsoft.cn/guides/introduction/product)**
+👉 **[Learn More](https://docs.openim.io/guides/introduction/product)**
-+ **[Source Code Deployment Guide](https://doc.rentsoft.cn/guides/gettingStarted/imSourceCodeDeployment)**
-+ **[Docker Deployment Guide](https://doc.rentsoft.cn/guides/gettingStarted/dockerCompose)**
++ **[Source Code Deployment Guide](https://docs.openim.io/guides/gettingStarted/imSourceCodeDeployment)**
++ **[Production deployment of Linux systems](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/install-openim-linux-system.md)**
++ **[Docker Deployment Guide](https://docs.openim.io/guides/gettingStarted/dockerCompose)**
+ **[Kubernetes Deployment Guide](https://github.com/openimsdk/open-im-server/tree/main/deployments)**
+* 1. [1. Introduction](#Introduction)
+* 2. [2. Prerequisites (Requires root permissions)](#PrerequisitesRequiresrootpermissions)
+* 3. [3. Create `openim-api` systemd unit template file](#Createopenim-apisystemdunittemplatefile)
+* 4. [4. Copy systemd unit template file to systemd config directory (Requires root permissions)](#CopysystemdunittemplatefiletosystemdconfigdirectoryRequiresrootpermissions)
+* 5. [5. Start systemd service](#Startsystemdservice)
+
+
+## 0. 0. Introduction
+
+Systemd is the default service management form for the latest Linux distributions, replacing the original init.
+
+The OpenIM system is a comprehensive suite of services tailored to address a wide variety of messaging needs. This guide will walk you through the steps of setting up the OpenIM system services and provide insights into its usage.
+
+**Prerequisites:**
+
++ A Linux server with necessary privileges.
++ Ensure you have `systemctl` installed and running.
+
+
+## 1. 1. Deployment
+
+1. **Retrieve the Installation Script**:
+
+ Begin by obtaining the OpenIM installation script which will be utilized to deploy the entire OpenIM system.
+
+2. **Install OpenIM**:
+
+ To install all the components of OpenIM, run:
+
+ ```bash
+ ./scripts/install/install.sh -i
+ ```
+
+ or
+
+ ```bash
+ ./scripts/install/install.sh --install
+ ```
+
+ This will initiate the installation process for all OpenIM components.
+
+3. **Check the Status**:
+
+ Post installation, it is good practice to verify if all the services are running as expected:
+
+ ```bash
+ systemctl status openim.target
+ ```
+
+ This will list the status of all related services of OpenIM.
+
+**Maintenance & Management:**
+
+1. **Checking Individual Service Status**:
+
+ You can monitor the status of individual services with the following command:
+
+ ```bash
+ systemctl status
+ ```
+
+ For instance:
+
+ ```bash
+ systemctl status openim-api.service
+ ``
+
+2. **Starting and Stopping Services**:
+
+ If you wish to start or stop any specific service, you can do so with `systemctl start` or `systemctl stop` followed by the service name:
+
+ ```bash
+ systemctl start openim-api.service
+ systemctl stop openim-api.service
+ ```
+
+3. **Uninstalling OpenIM**:
+
+ In case you wish to remove the OpenIM components from your server, utilize:
+
+ ```bash
+ ./scripts/install/install.sh -u
+ ```
+
+ or
+
+ ```bash
+ ./scripts/install/install.sh --uninstall
+ ```
+
+ Ensure you take a backup of any important data before executing the uninstall command.
+
+4. **Logs & Troubleshooting**:
+
+ Logs play a pivotal role in understanding the system's operation and troubleshooting any issues. OpenIM logs can typically be found in the directory specified during installation, usually `${OPENIM_LOG_DIR}`.
+
+ Always refer to the logs when troubleshooting. Look for any error messages or warnings that might give insights into the issue at hand.
+
+
+**Note:**
+
++ `openim-api.service`: Manages the main API gateways for OpenIM communication.
++ `openim-crontask.service`: Manages scheduled tasks and jobs.
++ `openim-msggateway.service`: Takes care of message gateway operations.
++ `openim-msgtransfer.service`: Handles message transfer functionalities.
++ `openim-push.service`: Responsible for push notification services.
++ `openim-rpc-auth.service`: Manages RPC (Remote Procedure Call) for authentication.
++ `openim-rpc-conversation.service`: Manages RPC for conversations.
++ `openim-rpc-friend.service`: Handles RPC for friend-related operations.
++ `openim-rpc-group.service`: Manages group-related RPC operations.
++ `openim-rpc-msg.service`: Takes care of message RPCs.
++ `openim-rpc-third.service`: Deals with third-party integrations using RPC.
++ `openim-rpc-user.service`: Manages user-related RPC operations.
++ `openim.target`: A target that bundles all the above services for collective operations.
+
+
+**Viewing Logs with `journalctl`:**
+
+`systemctl` services usually log their output to the systemd journal, which you can access using the `journalctl` command.
+
+1. **View Logs for a Specific Service**:
+
+ To view the logs for a particular service, you can use:
+
+ ```bash
+ journalctl -u
+ ```
+
+ For example, to see the logs for the `openim-api.service`, you would use:
+
+ ```bash
+ journalctl -u openim-api.service
+ ```
+
+2. **Filtering Logs**:
+
+ + By Time
+
+ : If you wish to see logs since a specific time:
+
+ ```bash
+ journalctl -u openim-api.service --since "2023-10-28 12:00:00"
+ ```
+
+ + Most Recent Logs
+
+ : To view the most recent logs, you can combine
+`tail` functionality with `journalctl`:
+
+ ```bash
+ journalctl -u openim-api.service -n 100
+ ```
+
+3. **Continuous Monitoring of Logs**:
+
+ To see new log messages in real-time, you can use the `-f` flag, which mimics the behavior of `tail -f`:
+
+ ```bash
+ journalctl -u openim-api.service -f
+ ```
+
+### Continued Maintenance:
+
+1. **Regularly Check Service Status**:
+
+ It's good practice to routinely verify that all services are active and running. This can be done with:
+
+ ```bash
+ systemctl status openim-api.service openim-push.service openim-rpc-group.service openim-crontask.service openim-rpc-auth.service openim-rpc-msg.service openim-msggateway.service openim-rpc-conversation.service openim-rpc-third.service openim-msgtransfer.service openim-rpc-friend.service openim-rpc-user.service
+ ```
+
+2. **Update Services**:
+
+ Periodically, there might be updates or patches to the OpenIM system or its components. Make sure you keep the system updated. After updating any service, always reload the daemon and restart the service:
+
+ ```bash
+ systemctl daemon-reload
+ systemctl restart openim-api.service
+ ```
+
+3. **Backup Important Data**:
+
+ Regularly backup any configuration files, user data, and other essential data. This ensures that you can restore the system to a working state in case of failures.
+
+### Important `systemctl` and Logging Commands to Learn:
+
+1. **Start/Stop/Restart Services**:
+
+ ```bash
+ systemctl start
+ systemctl stop
+ systemctl restart
+ ```
+
+2. **Enable/Disable Services**:
+
+ If you want a service to start automatically at boot:
+
+ ```bash
+ systemctl enable
+ ```
+
+ To prevent it from starting at boot:
+
+ ```bash
+ systemctl disable
+ ```
+
+3. **Check Failed Services**:
+
+ To quickly check if any service has failed:
+
+ ```bash
+ systemctl --failed
+ ```
+
+4. **Log Rotation**:
+
+ `journalctl` logs can grow large. To clear all archived journal entries, use:
+
+ ```bash
+ journalctl --vacuum-time=1d
+ ```
+
+
+**Advanced requirements:**
+
+- Convenient service runtime log recording for problem analysis
+- Service management logs
+- Option to restart upon abnormal exit
+
+The daemon does not meet these advanced requirements.
+
+`nohup` only logs the service's runtime outputs and errors.
+
+Only systemd can fulfill all of the above requirements.
+
+> The default logs are enhanced with timestamps, usernames, service names, PIDs, etc., making them user-friendly. You can view logs of abnormal service exits. Advanced customization is possible through the configuration files in `/lib/systemd/system/`.
+
+In short, systemd is the current mainstream way to manage backend services on Linux, so I've abandoned `nohup` in my new versions of bash scripts, opting instead for systemd.
+
+## 2. Prerequisites (Requires root permissions)
+
+1. Configure `environment.sh` based on the comments.
+2. Create a data directory:
+
+```bash
+mkdir -p ${OPENIM_DATA_DIR}/{openim-api,openim-crontask}
+```
+
+3. Create a bin directory and copy `openim-api` and `openim-crontask` executable files:
+
+```bash
+source ./environment.sh
+mkdir -p ${OPENIM_INSTALL_DIR}/bin
+cp openim-api openim-crontask ${OPENIM_INSTALL_DIR}/bin
+```
+
+4. Copy the configuration files of `openim-api` and `openim-crontask` to the `${OPENIM_CONFIG_DIR}` directory:
+
+```bash
+mkdir -p ${OPENIM_CONFIG_DIR}
+cp openim-api.yaml openim-crontask.yaml ${OPENIM_CONFIG_DIR}
+```
+
+## 3. Create `openim-api` systemd unit template file
+
+For each OpenIM service, we will create a systemd unit template. Follow the steps below for each service:
+
+Run the following shell script to generate the `openim-api.service.template`:
+
+```bash
+source ./environment.sh
+cat > openim-api.service.template < $service.service.template <Copy systemd unit template file to systemd config directory (Requires root permissions)
+
+Ensure you have root permissions to perform this operation:
+
+```bash
+for service in "${services[@]}"
+do
+ sudo cp $service.service.template /etc/systemd/system/$service.service
+done
+...
+```
+
+## 5. Start systemd service
+
+To start the OpenIM services:
+
+```bash
+for service in "${services[@]}"
+do
+ sudo systemctl daemon-reload
+ sudo systemctl enable $service
+ sudo systemctl restart $service
+done
+```
diff --git a/docs/conversions/version.md b/docs/conversions/version.md
index 0980eaa27..95f736be4 100644
--- a/docs/conversions/version.md
+++ b/docs/conversions/version.md
@@ -7,6 +7,7 @@
- [Tag Management: The Cornerstone of Version Control](#tag-management-the-cornerstone-of-version-control)
- [Release Management: A Guided Tour](#release-management-a-guided-tour)
- [Milestones, Branching, and Addressing Major Bugs](#milestones-branching-and-addressing-major-bugs)
+ - [Version Skew Policy](#version-skew-policy)
- [Applying Principles: A Git Workflow Example](#applying-principles-a-git-workflow-example)
- [Docker Images Version Management](#docker-images-version-management)
@@ -77,6 +78,97 @@ When dealing with major bugs, we selectively merge the fix into the affected ver
We reinforce our approach to branch management and versioning with stringent testing protocols. Automated tests and code review sessions form vital components of maintaining a robust and reliable codebase.
+## Version Skew Policy
+
+This document describes the maximum version skew supported between various openim components. Specific cluster deployment tools may place additional restrictions on version skew.
+
+
+### Supported version skew
+
+In highly-available (HA) clusters, the newest and oldest `openim-api` instances must be within one minor version.
+
+### OpenIM Versioning, Branching, and Tag Strategy
+
+Similar to Kubernetes, OpenIM has a strict versioning, branching, and tag strategy to ensure compatibility among its various services and components. This document outlines the policies, especially focusing on the version skew supported between OpenIM's components. Given that the current version is v3.3, the policy references will be centered around this version.
+
+#### Supported Version Skew
+
+##### openim-api
+
+In highly-available (HA) clusters, the newest and oldest `openim-api` instances must be within one minor version.
+
+Example:
+
++ Newest `openim-api` is at v3.3
++ Other `openim-api` instances are supported at v3.3 and v3.2
+
+##### openim-rpc-* Components
+
+All `openim-rpc-*` components (e.g., `openim-rpc-auth`, `openim-rpc-conversation`, etc.) should adhere to the following rules:
+
+1. They must not be newer than `openim-api`.
+2. They may be up to one minor version older than `openim-api`.
+
+Example:
+
++ `openim-api` is at v3.3
++ All `openim-rpc-*` components are supported at v3.3 and v3.2
+
+Note: If version skew exists between `openim-api` instances in an HA cluster, this narrows the allowed `openim-rpc-*` components versions.
+
+##### Other OpenIM Services
+
+Other OpenIM services such as `openim-cmdutils`, `openim-crontask`, `openim-msggateway`, etc. should adhere to the following rules:
+
+1. These services must not be newer than `openim-api`.
+2. They are expected to match the `openim-api` minor version but may be up to one minor version older (to allow live upgrades).
+
+Example:
+
++ `openim-api` is at v3.3
++ `openim-msggateway`, `openim-cmdutils`, and other services are supported at v3.3 and v3.2
+
+#### Supported Component Upgrade Order
+
+The version skew policy has implications on the order in which components should be upgraded. Below is the recommended order to transition an existing cluster from version v3.2 to v3.3:
+
+##### openim-api
+
+Pre-requisites:
+
+1. In a single-instance cluster, the existing `openim-api` instance is v3.2.
+2. In an HA cluster, all `openim-api` instances are at v3.2 or v3.3.
+3. All `openim-rpc-*` and other OpenIM services communicating with this server are at version v3.2.
+
+Upgrade Procedure:
+
+1. Upgrade `openim-api` to v3.3.
+
+##### openim-rpc-* Components
+
+Pre-requisites:
+
+1. The `openim-api` instances these components communicate with are at v3.3.
+
+Upgrade Procedure:
+
+2. Upgrade all `openim-rpc-*` components to v3.3.
+
+##### Other OpenIM Services
+
+Pre-requisites:
+
+1. The `openim-api` instances these services communicate with are at v3.3.
+
+Upgrade Procedure:
+
+2. Upgrade other OpenIM services such as `openim-msggateway`, `openim-cmdutils`, etc., to v3.3.
+
+#### Conclusion
+
+Just like Kubernetes, it's essential for OpenIM to have a strict versioning and upgrade policy to ensure seamless operation and compatibility among its various services. Adhering to the policies outlined above will help in achieving this goal.
+
+
## Applying Principles: A Git Workflow Example
The workflow to address a bug fix might follow these steps:
diff --git a/go.mod b/go.mod
index 4d4ed879b..82e38e8e3 100644
--- a/go.mod
+++ b/go.mod
@@ -44,6 +44,7 @@ require (
github.com/go-sql-driver/mysql v1.7.1
github.com/redis/go-redis/v9 v9.2.1
github.com/tencentyun/cos-go-sdk-v5 v0.7.45
+ gopkg.in/src-d/go-git.v4 v4.13.1
)
require (
@@ -65,6 +66,7 @@ require (
github.com/eapache/go-resiliency v1.4.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
+ github.com/emirpasic/gods v1.12.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
@@ -79,6 +81,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
+ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
@@ -87,6 +90,7 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
+ github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
@@ -94,6 +98,7 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
+ github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
@@ -108,8 +113,11 @@ require (
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/xid v1.5.0 // indirect
+ github.com/sergi/go-diff v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
+ github.com/src-d/gcfg v1.4.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
+ github.com/xanzy/ssh-agent v0.2.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
@@ -129,6 +137,8 @@ require (
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect
+ gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
+ gopkg.in/warnings.v0 v0.1.2 // indirect
)
require (
diff --git a/go.sum b/go.sum
index 0dd6cc940..c64fc8d68 100644
--- a/go.sum
+++ b/go.sum
@@ -20,11 +20,17 @@ 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.30 h1:MiHO6PyQMR9ojBHNnSFxCHLmsoE2xZqaiYj975JiZnM=
github.com/OpenIMSDK/protocol v0.0.30/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
-github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ=
-github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
+github.com/OpenIMSDK/tools v0.0.15 h1:FF3m0TQUG56pJC15a11jmBG6Y1EjXarEW4JV3CBF/Jc=
+github.com/OpenIMSDK/tools v0.0.15/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
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=
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible h1:Sg/2xHwDrioHpxTN6WMiwbXTpUEinBpHsN7mG21Rc2k=
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
+github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
+github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
@@ -49,6 +55,7 @@ github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5P
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
+github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -65,10 +72,13 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
+github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
+github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
@@ -79,6 +89,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
+github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
+github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
@@ -165,6 +177,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
@@ -177,6 +191,7 @@ github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh6
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
+github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
@@ -186,6 +201,8 @@ github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
+github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
@@ -195,7 +212,11 @@ github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
@@ -217,6 +238,8 @@ github.com/minio/minio-go/v7 v7.0.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurw
github.com/minio/minio-go/v7 v7.0.63/go.mod h1:Q6X7Qjb7WMhvG65qKf4gUgA5XaiSox74kR1uAEjxRS4=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
@@ -246,10 +269,12 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
+github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ=
github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -273,13 +298,18 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
+github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
+github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
@@ -301,6 +331,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
+github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
+github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
@@ -326,7 +358,9 @@ go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -351,6 +385,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
@@ -379,7 +414,9 @@ golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -401,6 +438,7 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
+golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -417,6 +455,7 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
@@ -464,12 +503,21 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
+gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
+gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=
+gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
+gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
+gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
+gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/internal/push/push_to_client.go b/internal/push/push_to_client.go
index ba0d65b39..8f671c21d 100644
--- a/internal/push/push_to_client.go
+++ b/internal/push/push_to_client.go
@@ -222,7 +222,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
// log.ZError(ctx, "GetRecvMsgNotNotifyUserIDs failed", err, "groupID", groupID)
return err
}
- needOfflinePushUserIDs = utils.DifferenceString(notNotificationUserIDs, needOfflinePushUserIDs)
+ needOfflinePushUserIDs = utils.SliceSub(needOfflinePushUserIDs, notNotificationUserIDs)
}
// Use offline push messaging
if len(needOfflinePushUserIDs) > 0 {
diff --git a/internal/rpc/msg/sync_msg.go b/internal/rpc/msg/sync_msg.go
index cfd90920c..7c67ff05f 100644
--- a/internal/rpc/msg/sync_msg.go
+++ b/internal/rpc/msg/sync_msg.go
@@ -64,6 +64,7 @@ func (m *msgServer) PullMessageBySeqs(
}
if len(msgs) == 0 {
log.ZWarn(ctx, "not have msgs", nil, "conversationID", seq.ConversationID, "seq", seq)
+
continue
}
resp.Msgs[seq.ConversationID] = &sdkws.PullMsgs{Msgs: msgs, IsEnd: isEnd}
@@ -75,6 +76,7 @@ func (m *msgServer) PullMessageBySeqs(
minSeq, maxSeq, notificationMsgs, err := m.MsgDatabase.GetMsgBySeqs(ctx, req.UserID, seq.ConversationID, seqs)
if err != nil {
log.ZWarn(ctx, "GetMsgBySeqs error", err, "conversationID", seq.ConversationID, "seq", seq)
+
continue
}
var isEnd bool
@@ -86,6 +88,7 @@ func (m *msgServer) PullMessageBySeqs(
}
if len(notificationMsgs) == 0 {
log.ZWarn(ctx, "not have notificationMsgs", nil, "conversationID", seq.ConversationID, "seq", seq)
+
continue
}
resp.NotificationMsgs[seq.ConversationID] = &sdkws.PullMsgs{Msgs: notificationMsgs, IsEnd: isEnd}
diff --git a/manifest/build-docker.sh b/manifest/build-docker.sh
deleted file mode 100755
index 648e6370d..000000000
--- a/manifest/build-docker.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-IMAGEHUB="registry.cn-shenzhen.aliyuncs.com/huanglin_hub"
-PROJECT=$1
-ALLPRO="all"
-servers=(openim-api openim-crontask openim-msggateway openim-msgtransfer openim-push openim-rpc-auth openim-rpc-conversation openim-rpc-friend openim-rpc-group openim-rpc-msg openim-rpc-third openim-rpc-user)
-
-
-if [ "$1" != "" ]
-then
- if [[ "${servers[@]}" =~ "${1}" ]]
- then
- echo "building ${PROJECT}"
- DOCKER_PUSHIMG=${IMAGEHUB}/${PROJECT}:dev
- docker rmi ${DOCKER_PUSHIMG}
- docker build -f manifest/dockerfiles/${PROJECT}/Dockerfile -t ${DOCKER_PUSHIMG} .
- docker push ${DOCKER_PUSHIMG}
- elif [[ ! "${servers[@]}" =~ "${1}" ]]
- then
- if [ ${PROJECT} == ${ALLPRO} ]
- then
- echo "building allproject"
- for element in ${servers[@]}
- do
- SUB_IMG=${element}
- SUB_PUSHIMG=${IMAGEHUB}/${element}:dev
- docker rmi ${SUB_PUSHIMG}
- docker build -f manifest/dockerfiles/${SUB_IMG}/Dockerfile -t ${SUB_PUSHIMG} .
- docker push ${SUB_PUSHIMG}
- done
- else
- echo "输入的项目名称不正确"
- fi
- fi
-else
- echo "请传入一个参数"
-fi
\ No newline at end of file
diff --git a/manifest/dockerfiles/openim-api/Dockerfile b/manifest/dockerfiles/openim-api/Dockerfile
deleted file mode 100644
index c5198d2ad..000000000
--- a/manifest/dockerfiles/openim-api/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-api/openim-api cmd/openim-api/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-api/openim-api /app/bin/
-ENTRYPOINT ["/app/bin/openim-api"]
diff --git a/manifest/dockerfiles/openim-crontask/Dockerfile b/manifest/dockerfiles/openim-crontask/Dockerfile
deleted file mode 100644
index bba54b2e2..000000000
--- a/manifest/dockerfiles/openim-crontask/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-crontask/openim-crontask cmd/openim-crontask/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-crontask/openim-crontask /app/bin/
-ENTRYPOINT ["/app/bin/openim-crontask"]
diff --git a/manifest/dockerfiles/openim-msggateway/Dockerfile b/manifest/dockerfiles/openim-msggateway/Dockerfile
deleted file mode 100644
index 582178013..000000000
--- a/manifest/dockerfiles/openim-msggateway/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-msggateway/openim-msggateway cmd/openim-msggateway/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-msggateway/openim-msggateway /app/bin/
-ENTRYPOINT ["/app/bin/openim-msggateway"]
diff --git a/manifest/dockerfiles/openim-msgtransfer/Dockerfile b/manifest/dockerfiles/openim-msgtransfer/Dockerfile
deleted file mode 100644
index 1e08eb38a..000000000
--- a/manifest/dockerfiles/openim-msgtransfer/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-msgtransfer/openim-msgtransfer cmd/openim-msgtransfer/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-msgtransfer/openim-msgtransfer /app/bin/
-ENTRYPOINT ["/app/bin/openim-msgtransfer"]
diff --git a/manifest/dockerfiles/openim-push/Dockerfile b/manifest/dockerfiles/openim-push/Dockerfile
deleted file mode 100644
index c1ae3ed84..000000000
--- a/manifest/dockerfiles/openim-push/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-push/openim-push cmd/openim-push/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-push/openim-push /app/bin/
-ENTRYPOINT ["/app/bin/openim-push"]
diff --git a/manifest/dockerfiles/openim-rpc-auth/Dockerfile b/manifest/dockerfiles/openim-rpc-auth/Dockerfile
deleted file mode 100644
index 5124da7a1..000000000
--- a/manifest/dockerfiles/openim-rpc-auth/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-auth/openim-rpc-auth cmd/openim-rpc/openim-rpc-auth/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-auth/openim-rpc-auth /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-auth"]
diff --git a/manifest/dockerfiles/openim-rpc-conversation/Dockerfile b/manifest/dockerfiles/openim-rpc-conversation/Dockerfile
deleted file mode 100644
index 539d441b9..000000000
--- a/manifest/dockerfiles/openim-rpc-conversation/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-conversation/openim-rpc-conversation cmd/openim-rpc/openim-rpc-conversation/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-conversation/openim-rpc-conversation /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-conversation"]
diff --git a/manifest/dockerfiles/openim-rpc-friend/Dockerfile b/manifest/dockerfiles/openim-rpc-friend/Dockerfile
deleted file mode 100644
index 9927c1d30..000000000
--- a/manifest/dockerfiles/openim-rpc-friend/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-friend/openim-rpc-friend cmd/openim-rpc/openim-rpc-friend/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-friend/openim-rpc-friend /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-friend"]
diff --git a/manifest/dockerfiles/openim-rpc-group/Dockerfile b/manifest/dockerfiles/openim-rpc-group/Dockerfile
deleted file mode 100644
index 754151156..000000000
--- a/manifest/dockerfiles/openim-rpc-group/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-group/openim-rpc-group cmd/openim-rpc/openim-rpc-group/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-group/openim-rpc-group /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-group"]
diff --git a/manifest/dockerfiles/openim-rpc-msg/Dockerfile b/manifest/dockerfiles/openim-rpc-msg/Dockerfile
deleted file mode 100644
index 0f942ba8e..000000000
--- a/manifest/dockerfiles/openim-rpc-msg/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-msg/openim-rpc-msg cmd/openim-rpc/openim-rpc-msg/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-msg/openim-rpc-msg /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-msg"]
diff --git a/manifest/dockerfiles/openim-rpc-third/Dockerfile b/manifest/dockerfiles/openim-rpc-third/Dockerfile
deleted file mode 100644
index a1391c0c3..000000000
--- a/manifest/dockerfiles/openim-rpc-third/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-third/openim-rpc-third cmd/openim-rpc/openim-rpc-third/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-third/openim-rpc-third /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-third"]
diff --git a/manifest/dockerfiles/openim-rpc-user/Dockerfile b/manifest/dockerfiles/openim-rpc-user/Dockerfile
deleted file mode 100644
index b45b4aa2f..000000000
--- a/manifest/dockerfiles/openim-rpc-user/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-user/openim-rpc-user cmd/openim-rpc/openim-rpc-user/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-user/openim-rpc-user /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-user"]
diff --git a/pkg/common/cmd/msg_gateway.go b/pkg/common/cmd/msg_gateway.go
index c96bbd7af..358b79f9b 100644
--- a/pkg/common/cmd/msg_gateway.go
+++ b/pkg/common/cmd/msg_gateway.go
@@ -15,10 +15,11 @@
package cmd
import (
+ "log"
+
"github.com/openimsdk/open-im-server/v3/internal/msggateway"
- config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
+ v3config "github.com/openimsdk/open-im-server/v3/pkg/common/config"
- //"github.com/openimsdk/open-im-server/internal/msggateway".
"github.com/spf13/cobra"
"github.com/OpenIMSDK/protocol/constant"
@@ -39,7 +40,10 @@ func (m *MsgGatewayCmd) AddWsPortFlag() {
}
func (m *MsgGatewayCmd) getWsPortFlag(cmd *cobra.Command) int {
- port, _ := cmd.Flags().GetInt(constant.FlagWsPort)
+ port, err := cmd.Flags().GetInt(constant.FlagWsPort)
+ if err != nil {
+ log.Println("Error getting ws port flag:", err)
+ }
if port == 0 {
port = m.PortFromConfig(constant.FlagWsPort)
}
@@ -58,9 +62,9 @@ func (m *MsgGatewayCmd) Exec() error {
}
func (m *MsgGatewayCmd) GetPortFromConfig(portType string) int {
if portType == constant.FlagWsPort {
- return config2.Config.LongConnSvr.OpenImWsPort[0]
+ return v3config.Config.LongConnSvr.OpenImWsPort[0]
} else if portType == constant.FlagPort {
- return config2.Config.LongConnSvr.OpenImMessageGatewayPort[0]
+ return v3config.Config.LongConnSvr.OpenImMessageGatewayPort[0]
} else if portType == constant.FlagPrometheusPort {
return 0
} else {
diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go
index 7bff0f798..d2d2b5009 100644
--- a/pkg/common/cmd/root.go
+++ b/pkg/common/cmd/root.go
@@ -131,7 +131,10 @@ func (r *RootCmd) AddPortFlag() {
}
func (r *RootCmd) getPortFlag(cmd *cobra.Command) int {
- port, _ := cmd.Flags().GetInt(constant.FlagPort)
+ port, err := cmd.Flags().GetInt(constant.FlagPort)
+ if err != nil {
+ fmt.Println("Error getting ws port flag:", err)
+ }
if port == 0 {
port = r.PortFromConfig(constant.FlagPort)
}
diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go
index 0e5ea5e43..16b8c99fa 100644
--- a/pkg/common/db/relation/mysql_init.go
+++ b/pkg/common/db/relation/mysql_init.go
@@ -18,15 +18,12 @@ import (
"fmt"
"time"
- mysqldriver "github.com/go-sql-driver/mysql"
- "gorm.io/driver/mysql"
-
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mw/specialerror"
-
+ mysqldriver "github.com/go-sql-driver/mysql"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
-
+ "gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
@@ -35,56 +32,80 @@ const (
maxRetry = 100 // number of retries
)
-// newMysqlGormDB Initialize the database connection.
-func newMysqlGormDB() (*gorm.DB, error) {
- dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
- config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address[0], "mysql")
+type option struct {
+ Username string
+ Password string
+ Address []string
+ Database string
+ LogLevel int
+ SlowThreshold int
+ MaxLifeTime int
+ MaxOpenConn int
+ MaxIdleConn int
+ Connect func(dsn string, maxRetry int) (*gorm.DB, error)
+}
- db, err := connectToDatabase(dsn, maxRetry)
- if err != nil {
- panic(err.Error() + " Open failed " + dsn)
- }
- sqlDB, err := db.DB()
+// newMysqlGormDB Initialize the database connection.
+func newMysqlGormDB(o *option) (*gorm.DB, error) {
+ err := maybeCreateTable(o)
if err != nil {
return nil, err
}
- defer sqlDB.Close()
- sql := fmt.Sprintf(
- "CREATE DATABASE IF NOT EXISTS %s default charset utf8mb4 COLLATE utf8mb4_unicode_ci;",
- config.Config.Mysql.Database,
- )
- err = db.Exec(sql).Error
- if err != nil {
- return nil, fmt.Errorf("init db %w", err)
- }
- dsn = fmt.Sprintf(
- "%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
- config.Config.Mysql.Username,
- config.Config.Mysql.Password,
- config.Config.Mysql.Address[0],
- config.Config.Mysql.Database,
- )
+ dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
+ o.Username, o.Password, o.Address[0], o.Database)
sqlLogger := log.NewSqlLogger(
- logger.LogLevel(config.Config.Mysql.LogLevel),
+ logger.LogLevel(o.LogLevel),
true,
- time.Duration(config.Config.Mysql.SlowThreshold)*time.Millisecond,
+ time.Duration(o.SlowThreshold)*time.Millisecond,
)
- db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
+ db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{
Logger: sqlLogger,
})
if err != nil {
return nil, err
}
- sqlDB, err = db.DB()
+ sqlDB, err := db.DB()
if err != nil {
return nil, err
}
- sqlDB.SetConnMaxLifetime(time.Second * time.Duration(config.Config.Mysql.MaxLifeTime))
- sqlDB.SetMaxOpenConns(config.Config.Mysql.MaxOpenConn)
- sqlDB.SetMaxIdleConns(config.Config.Mysql.MaxIdleConn)
+ sqlDB.SetConnMaxLifetime(time.Second * time.Duration(o.MaxLifeTime))
+ sqlDB.SetMaxOpenConns(o.MaxOpenConn)
+ sqlDB.SetMaxIdleConns(o.MaxIdleConn)
return db, nil
}
+// maybeCreateTable creates a database if it does not exists.
+func maybeCreateTable(o *option) error {
+ dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
+ o.Username, o.Password, o.Address[0], "mysql")
+
+ var db *gorm.DB
+ var err error
+ if f := o.Connect; f != nil {
+ db, err = f(dsn, maxRetry)
+ } else {
+ db, err = connectToDatabase(dsn, maxRetry)
+ }
+ if err != nil {
+ panic(err.Error() + " Open failed " + dsn)
+ }
+
+ sqlDB, err := db.DB()
+ if err != nil {
+ return err
+ }
+ defer sqlDB.Close()
+ sql := fmt.Sprintf(
+ "CREATE DATABASE IF NOT EXISTS `%s` default charset utf8mb4 COLLATE utf8mb4_unicode_ci",
+ o.Database,
+ )
+ err = db.Exec(sql).Error
+ if err != nil {
+ return fmt.Errorf("init db %w", err)
+ }
+ return nil
+}
+
// connectToDatabase Connection retry for mysql.
func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
var db *gorm.DB
@@ -106,7 +127,18 @@ func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
func NewGormDB() (*gorm.DB, error) {
specialerror.AddReplace(gorm.ErrRecordNotFound, errs.ErrRecordNotFound)
specialerror.AddErrHandler(replaceDuplicateKey)
- return newMysqlGormDB()
+
+ return newMysqlGormDB(&option{
+ Username: config.Config.Mysql.Username,
+ Password: config.Config.Mysql.Password,
+ Address: config.Config.Mysql.Address,
+ Database: config.Config.Mysql.Database,
+ LogLevel: config.Config.Mysql.LogLevel,
+ SlowThreshold: config.Config.Mysql.SlowThreshold,
+ MaxLifeTime: config.Config.Mysql.MaxLifeTime,
+ MaxOpenConn: config.Config.Mysql.MaxOpenConn,
+ MaxIdleConn: config.Config.Mysql.MaxIdleConn,
+ })
}
func replaceDuplicateKey(err error) errs.CodeError {
diff --git a/pkg/common/db/relation/mysql_init_test.go b/pkg/common/db/relation/mysql_init_test.go
new file mode 100644
index 000000000..c321dfd9f
--- /dev/null
+++ b/pkg/common/db/relation/mysql_init_test.go
@@ -0,0 +1,121 @@
+package relation
+
+import (
+ "context"
+ "database/sql"
+ "database/sql/driver"
+ "errors"
+ "fmt"
+ "reflect"
+ "testing"
+
+ "gorm.io/driver/mysql"
+ "gorm.io/gorm"
+ "gorm.io/gorm/logger"
+)
+
+func TestMaybeCreateTable(t *testing.T) {
+ t.Run("normal", func(t *testing.T) {
+ err := maybeCreateTable(&option{
+ Username: "root",
+ Password: "openIM123",
+ Address: []string{"172.28.0.1:13306"},
+ Database: "openIM_v3",
+ LogLevel: 4,
+ SlowThreshold: 500,
+ MaxOpenConn: 1000,
+ MaxIdleConn: 100,
+ MaxLifeTime: 60,
+ Connect: connect(expectExec{
+ query: "CREATE DATABASE IF NOT EXISTS `openIM_v3` default charset utf8mb4 COLLATE utf8mb4_unicode_ci",
+ args: nil,
+ }),
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ })
+
+ t.Run("im-db", func(t *testing.T) {
+ err := maybeCreateTable(&option{
+ Username: "root",
+ Password: "openIM123",
+ Address: []string{"172.28.0.1:13306"},
+ Database: "im-db",
+ LogLevel: 4,
+ SlowThreshold: 500,
+ MaxOpenConn: 1000,
+ MaxIdleConn: 100,
+ MaxLifeTime: 60,
+ Connect: connect(expectExec{
+ query: "CREATE DATABASE IF NOT EXISTS `im-db` default charset utf8mb4 COLLATE utf8mb4_unicode_ci",
+ args: nil,
+ }),
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ })
+
+ t.Run("err", func(t *testing.T) {
+ e := errors.New("e")
+ err := maybeCreateTable(&option{
+ Username: "root",
+ Password: "openIM123",
+ Address: []string{"172.28.0.1:13306"},
+ Database: "openIM_v3",
+ LogLevel: 4,
+ SlowThreshold: 500,
+ MaxOpenConn: 1000,
+ MaxIdleConn: 100,
+ MaxLifeTime: 60,
+ Connect: connect(expectExec{
+ err: e,
+ }),
+ })
+ if !errors.Is(err, e) {
+ t.Fatalf("err not is e: %v", err)
+ }
+ })
+}
+
+func connect(e expectExec) func(string, int) (*gorm.DB, error) {
+ return func(string, int) (*gorm.DB, error) {
+ return gorm.Open(mysql.New(mysql.Config{
+ SkipInitializeWithVersion: true,
+ Conn: sql.OpenDB(e),
+ }), &gorm.Config{
+ Logger: logger.Discard,
+ })
+ }
+}
+
+type expectExec struct {
+ err error
+ query string
+ args []driver.NamedValue
+}
+
+func (c expectExec) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
+ if c.err != nil {
+ return nil, c.err
+ }
+ if query != c.query {
+ return nil, fmt.Errorf("query mismatch. expect: %s, got: %s", c.query, query)
+ }
+ if reflect.DeepEqual(args, c.args) {
+ return nil, fmt.Errorf("args mismatch. expect: %v, got: %v", c.args, args)
+ }
+ return noEffectResult{}, nil
+}
+
+func (e expectExec) Connect(context.Context) (driver.Conn, error) { return e, nil }
+func (expectExec) Driver() driver.Driver { panic("not implemented") }
+func (expectExec) Prepare(query string) (driver.Stmt, error) { panic("not implemented") }
+func (expectExec) Close() (e error) { return }
+func (expectExec) Begin() (driver.Tx, error) { panic("not implemented") }
+
+type noEffectResult struct{}
+
+func (noEffectResult) LastInsertId() (i int64, e error) { return }
+func (noEffectResult) RowsAffected() (i int64, e error) { return }
diff --git a/pkg/common/version/base.go b/pkg/common/version/base.go
new file mode 100644
index 000000000..ac214269f
--- /dev/null
+++ b/pkg/common/version/base.go
@@ -0,0 +1,47 @@
+package version
+
+// Base version information.
+//
+// This is the fallback data used when version information from git is not
+// provided via go ldflags. It provides an approximation of the Kubernetes
+// version for ad-hoc builds (e.g. `go build`) that cannot get the version
+// information from git.
+//
+// If you are looking at these fields in the git tree, they look
+// strange. They are modified on the fly by the build process. The
+// in-tree values are dummy values used for "git archive", which also
+// works for GitHub tar downloads.
+//
+// When releasing a new Kubernetes version, this file is updated by
+// build/mark_new_version.sh to reflect the new version, and then a
+// git annotated tag (using format vX.Y where X == Major version and Y
+// == Minor version) is created to point to the commit that updates
+var (
+ // TODO: Deprecate gitMajor and gitMinor, use only gitVersion
+ // instead. First step in deprecation, keep the fields but make
+ // them irrelevant. (Next we'll take it out, which may muck with
+ // scripts consuming the kubectl version output - but most of
+ // these should be looking at gitVersion already anyways.)
+ gitMajor string = "" // major version, always numeric
+ gitMinor string = "" // minor version, numeric possibly followed by "+"
+
+ // semantic version, derived by build scripts (see
+ // https://github.com/kubernetes/sig-release/blob/master/release-engineering/versioning.md#kubernetes-release-versioning
+ // https://kubernetes.io/releases/version-skew-policy/
+ // for a detailed discussion of this field)
+ //
+ // TODO: This field is still called "gitVersion" for legacy
+ // reasons. For prerelease versions, the build metadata on the
+ // semantic version is a git hash, but the version itself is no
+ // longer the direct output of "git describe", but a slight
+ // translation to be semver compliant.
+
+ // NOTE: The $Format strings are replaced during 'git archive' thanks to the
+ // companion .gitattributes file containing 'export-subst' in this same
+ // directory. See also https://git-scm.com/docs/gitattributes
+ gitVersion string = "latest"
+ gitCommit string = "" // sha1 from git, output of $(git rev-parse HEAD)
+ gitTreeState string = "" // state of git tree, either "clean" or "dirty"
+
+ buildDate string = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
+)
diff --git a/pkg/common/version/types.go b/pkg/common/version/types.go
new file mode 100644
index 000000000..ee4664149
--- /dev/null
+++ b/pkg/common/version/types.go
@@ -0,0 +1,30 @@
+package version
+
+// Info contains versioning information.
+// TODO: Add []string of api versions supported? It's still unclear
+// how we'll want to distribute that information.
+type Info struct {
+ Major string `json:"major,omitempty"`
+ Minor string `json:"minor,omitempty"`
+ GitVersion string `json:"gitVersion"`
+ GitTreeState string `json:"gitTreeState,omitempty"`
+ GitCommit string `json:"gitCommit,omitempty"`
+ BuildDate string `json:"buildDate"`
+ GoVersion string `json:"goVersion"`
+ Compiler string `json:"compiler"`
+ Platform string `json:"platform"`
+}
+
+type Output struct {
+ OpenIMServerVersion Info `json:"OpenIMServerVersion,omitempty" yaml:"OpenIMServerVersion,omitempty"`
+ OpenIMClientVersion *OpenIMClientVersion `json:"OpenIMClientVersion,omitempty" yaml:"OpenIMClientVersion,omitempty"`
+}
+
+type OpenIMClientVersion struct {
+ ClientVersion string `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` //sdk core version
+}
+
+// String returns info as a human-friendly version string.
+func (info Info) String() string {
+ return info.GitVersion
+}
diff --git a/pkg/common/version/version.go b/pkg/common/version/version.go
new file mode 100644
index 000000000..b8ccfaf81
--- /dev/null
+++ b/pkg/common/version/version.go
@@ -0,0 +1,58 @@
+package version
+
+import (
+ "fmt"
+ "runtime"
+
+ "gopkg.in/src-d/go-git.v4"
+)
+
+// Get returns the overall codebase version. It's for detecting
+// what code a binary was built from.
+func Get() Info {
+ // These variables typically come from -ldflags settings and in
+ // their absence fallback to the settings in ./base.go
+ return Info{
+ Major: gitMajor,
+ Minor: gitMinor,
+ GitVersion: gitVersion,
+ GitTreeState: gitTreeState,
+ GitCommit: gitCommit,
+ BuildDate: buildDate,
+ GoVersion: runtime.Version(),
+ Compiler: runtime.Compiler,
+ Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
+ }
+}
+
+// GetClientVersion returns the git version of the OpenIM client repository
+func GetClientVersion() (*OpenIMClientVersion, error) {
+ clientVersion, err := getClientVersion()
+ if err != nil {
+ return nil, err
+ }
+ return &OpenIMClientVersion{
+ ClientVersion: clientVersion,
+ }, nil
+}
+
+func getClientVersion() (string, error) {
+ repo, err := git.PlainClone("/tmp/openim-sdk-core", false, &git.CloneOptions{
+ URL: "https://github.com/OpenIMSDK/openim-sdk-core",
+ })
+ if err != nil {
+ return "", fmt.Errorf("error cloning repository: %w", err)
+ }
+
+ ref, err := repo.Head()
+ if err != nil {
+ return "", fmt.Errorf("error getting head reference: %w", err)
+ }
+
+ return ref.Hash().String(), nil
+}
+
+// GetSingleVersion returns single version of sealer
+func GetSingleVersion() string {
+ return gitVersion
+}
diff --git a/scripts/check-all.sh b/scripts/check-all.sh
index 0d849dd50..23e2119d4 100755
--- a/scripts/check-all.sh
+++ b/scripts/check-all.sh
@@ -33,8 +33,9 @@ openim::log::info "\n# Begin to check all openim service"
# OpenIM status
# Elegant printing function
print_services_and_ports() {
- local -n service_names=$1
- local -n service_ports=$2
+ # 获取数组
+ declare -g service_names=("${!1}")
+ declare -g service_ports=("${!2}")
echo "+-------------------------+----------+"
echo "| Service Name | Port |"
diff --git a/scripts/install/environment.sh b/scripts/install/environment.sh
index c5407f5e3..f3f53e49e 100755
--- a/scripts/install/environment.sh
+++ b/scripts/install/environment.sh
@@ -69,7 +69,7 @@ def "ENV_FILE" ""${OPENIM_ROOT}"/scripts/install/environment.sh"
def "CHAT_BRANCH" "main"
def "SERVER_BRANCH" "main"
-# Choose the appropriate image address, the default is GITHUB image,
+# Choose the appropriate image address, the default is GITHUB image,
# you can choose docker hub, for Chinese users can choose Ali Cloud
# export IMAGE_REGISTRY="ghcr.io/openimsdk"
# export IMAGE_REGISTRY="openim"
@@ -78,6 +78,9 @@ def "IMAGE_REGISTRY" "ghcr.io/openimsdk"
# def "IMAGE_REGISTRY" "openim"
# def "IMAGE_REGISTRY" "registry.cn-hangzhou.aliyuncs.com/openimsdk"
+# Choose the appropriate image tag, the default is the latest version
+def "SERVER_IMAGE_TAG" "latest"
+
###################### OpenIM Docker Network ######################
# 设置 Docker 网络的网段
readonly DOCKER_BRIDGE_SUBNET=${DOCKER_BRIDGE_SUBNET:-'172.28.0.0/16'}
@@ -115,10 +118,10 @@ LAST_OCTET=$((LAST_OCTET + 1))
GRAFANA_NETWORK_ADDRESS=$(generate_ip)
###################### openim 配置 ######################
-# read: https://github.com/openimsdk/open-im-server/blob/main/deployment/init/README.md
+# read: https://github.com/openimsdk/open-im-server/blob/main/deployment/README.md
def "OPENIM_DATA_DIR" "/data/openim"
def "OPENIM_INSTALL_DIR" "/opt/openim"
-def "OPENIM_CONFIG_DIR" "/etc/openim"
+def "OPENIM_CONFIG_DIR" "/etc/openim/config"
def "OPENIM_LOG_DIR" "/var/log/openim"
def "CA_FILE" "${OPENIM_CONFIG_DIR}/cert/ca.pem"
@@ -138,14 +141,14 @@ def "OPENIM_CHAT_ADDRESS" "${DOCKER_BRIDGE_GATEWAY}" # OpenIM服务地址
def "OPENIM_CHAT_API_PORT" "10008" # OpenIM API端口
def "CHAT_API_LISTEN_IP" "" # OpenIM API的监听IP
-def "OPENIM_ADMIN_API_PORT" "10009" # OpenIM Admin API端口
-def "ADMIN_API_LISTEN_IP" "" # OpenIM Admin API的监听IP
+def "OPENIM_ADMIN_API_PORT" "10009" # OpenIM Admin API端口
+def "ADMIN_API_LISTEN_IP" "" # OpenIM Admin API的监听IP
-def "OPENIM_ADMIN_PORT" "30200" # OpenIM chat Admin端口
-def "OPENIM_CHAT_PORT" "30300" # OpenIM chat Admin的监听IP
+def "OPENIM_ADMIN_PORT" "30200" # OpenIM chat Admin端口
+def "OPENIM_CHAT_PORT" "30300" # OpenIM chat Admin的监听IP
-def "OPENIM_ADMIN_NAME" "admin" # openim-chat Admin用户名
-def "OPENIM_CHAT_NAME" "chat" # openim-chat chat用户名
+def "OPENIM_ADMIN_NAME" "admin" # openim-chat Admin用户名
+def "OPENIM_CHAT_NAME" "chat" # openim-chat chat用户名
# TODO 注意: 一般的配置都可以使用 def 函数来定义,如果是包含特殊字符,比如说:
# TODO readonly MSG_DESTRUCT_TIME=${MSG_DESTRUCT_TIME:-'0 2 * * *'}
@@ -306,10 +309,10 @@ def "GETUI_INTENT" "" # GeTui推送意图
def "GETUI_CHANNEL_ID" "" # GeTui渠道ID
def "GETUI_CHANNEL_NAME" "" # GeTui渠道名称
def "FCM_SERVICE_ACCOUNT" "x.json" # FCM服务账户
-def "JPNS_APP_KEY" "" # JPNS应用密钥
-def "JPNS_MASTER_SECRET" "" # JPNS主密钥
-def "JPNS_PUSH_URL" "" # JPNS推送URL
-def "JPNS_PUSH_INTENT" "" # JPNS推送意图
+def "JPNS_APP_KEY" "" # JPNS应用密钥
+def "JPNS_MASTER_SECRET" "" # JPNS主密钥
+def "JPNS_PUSH_URL" "" # JPNS推送URL
+def "JPNS_PUSH_INTENT" "" # JPNS推送意图
def "MANAGER_USERID_1" "openIM123456" # 管理员ID 1
def "MANAGER_USERID_2" "openIM654321" # 管理员ID 2
def "MANAGER_USERID_3" "openIMAdmin" # 管理员ID 3
diff --git a/scripts/install/install.sh b/scripts/install/install.sh
index 9f1698a5b..915eef3f6 100755
--- a/scripts/install/install.sh
+++ b/scripts/install/install.sh
@@ -51,15 +51,9 @@
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-msggateway.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-msgtransfer.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-push.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-rpc.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-crontask.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-api.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-man.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-tools.sh
-source "${OPENIM_ROOT}"/scripts/install/test.sh
+${OPENIM_ROOT}/scripts/install/openim-man.sh
+${OPENIM_ROOT}/scripts/install/openim-tools.sh
+${OPENIM_ROOT}/scripts/install/test.sh
# Detailed help function
function openim::install::show_help() {
@@ -79,16 +73,26 @@ function openim::install::show_help() {
function openim::install::install_openim()
{
+ openim::common::sudo "mkdir -p ${OPENIM_DATA_DIR} ${OPENIM_INSTALL_DIR} ${OPENIM_CONFIG_DIR} ${OPENIM_LOG_DIR}"
openim::log::info "check openim dependency"
+ openim::common::sudo "cp -r ${OPENIM_ROOT}/config/* ${OPENIM_CONFIG_DIR}/"
+
+ echo ${LINUX_PASSWORD} | sudo -S bash -c \
+ "${OPENIM_ROOT}/scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.yaml > ${OPENIM_CONFIG_DIR}/config.yaml"
+
openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}
- openim::msggateway::install || return 1
- openim::msgtransfer::install || return 1
- openim::push::install || return 1
- openim::rpc::install || return 1
- openim::crontask::install || return 1
- openim::api::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh openim::msggateway::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh openim::msgtransfer::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-push.sh openim::push::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-crontask.sh openim::crontask::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-rpc.sh openim::rpc::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-api.sh openim::api::install || return 1
+ openim::common::sudo "cp -r ${OPENIM_ROOT}/deployments/templates/openim.target /etc/systemd/system/openim.target"
+ openim::common::sudo "systemctl daemon-reload"
+ openim::common::sudo "systemctl restart openim.target"
+ openim::common::sudo "systemctl enable openim.target"
openim::log::success "openim install success"
}
@@ -96,13 +100,18 @@ function openim::uninstall::uninstall_openim()
{
openim::log::info "uninstall openim"
- openim::msggateway::uninstall || return 1
- openim::msgtransfer::uninstall || return 1
- openim::push::uninstall || return 1
- openim::rpc::uninstall || return 1
- openim::crontask::uninstall || return 1
- openim::api::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh openim::msggateway::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh openim::msgtransfer::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-push.sh openim::push::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-crontask.sh openim::crontask::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-rpc.sh openim::rpc::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-api.sh openim::api::uninstall || return 1
+ set +o errexit
+ openim::common::sudo "systemctl stop openim.target"
+ openim::common::sudo "systemctl disable openim.target"
+ openim::common::sudo "rm -f /etc/systemd/system/openim.target"
+ set -o errexit
openim::log::success "openim uninstall success"
}
@@ -110,12 +119,12 @@ function openim::install::status()
{
openim::log::info "check openim status"
- openim::msggateway::status || return 1
- openim::msgtransfer::status || return 1
- openim::push::status || return 1
- openim::rpc::status || return 1
- openim::crontask::status || return 1
- openim::api::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh openim::msggateway::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh openim::msgtransfer::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-push.sh openim::push::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-crontask.sh openim::crontask::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-rpc.sh openim::rpc::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-api.sh openim::api::status || return 1
openim::log::success "openim status success"
}
diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh
index 5239b95e7..a2d40b777 100755
--- a/scripts/install/openim-api.sh
+++ b/scripts/install/openim-api.sh
@@ -92,21 +92,70 @@ function openim::api::start_service() {
###################################### Linux Systemd ######################################
SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service"
+# Print the necessary information after installation
+function openim::api::info() {
+cat << EOF
+openim-api listen on: ${OPENIM_API_HOST}:${API_OPENIM_PORT}
+EOF
+}
+
+# install openim-api
function openim::api::install() {
openim::log::info "Installing ${SERVER_NAME} ..."
+
+ pushd "${OPENIM_ROOT}"
+
+ # 1. Build openim-api
+ make build BINS=${SERVER_NAME}
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}"
+
+ # 2. Generate and install the openim-api configuration file (config)
+ openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/config.yaml"
+
+ # 3. Create and install the ${SERVER_NAME} systemd unit file
+ echo ${LINUX_PASSWORD} | sudo -S bash -c \
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
+ openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
+
+ # 4. Start the openim-api service
+ openim::common::sudo "systemctl daemon-reload"
+ openim::common::sudo "systemctl restart ${SERVER_NAME}"
+ openim::common::sudo "systemctl enable ${SERVER_NAME}"
+ openim::api::status || return 1
+ openim::api::info
+
+ openim::log::info "install ${SERVER_NAME} successfully"
+ popd
}
+# Unload
function openim::api::uninstall() {
openim::log::info "Uninstalling ${SERVER_NAME} ..."
+ set +o errexit
+ openim::common::sudo "systemctl stop ${SERVER_NAME}"
+ openim::common::sudo "systemctl disable ${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
+ set -o errexit
+ openim::log::info "uninstall ${SERVER_NAME} successfully"
}
+# Status Check
function openim::api::status() {
openim::log::info "Checking ${SERVER_NAME} status ..."
+ # Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully.
+ systemctl status ${SERVER_NAME}|grep -q 'active' || {
+ openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly"
+ return 1
+ }
+
openim::util::check_ports ${OPENIM_API_PORT_LISTARIES[@]}
}
if [[ "$*" =~ openim::api:: ]];then
- eval $*
-fi
\ No newline at end of file
+ eval $*
+fi
diff --git a/scripts/install/openim-crontask.sh b/scripts/install/openim-crontask.sh
index 455dafa8b..49e018ad1 100755
--- a/scripts/install/openim-crontask.sh
+++ b/scripts/install/openim-crontask.sh
@@ -51,7 +51,7 @@ function openim::crontask::start()
openim::util::stop_services_with_name ${OPENIM_CRONTASK_BINARY}
openim::log::status "start cron_task process, path: ${OPENIM_CRONTASK_BINARY}"
- nohup ${OPENIM_CRONTASK_BINARY} >> ${LOG_FILE} 2>&1 &
+ nohup ${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG} >> ${LOG_FILE} 2>&1 &
openim::util::check_process_names ${SERVER_NAME}
}
@@ -72,18 +72,16 @@ function openim::crontask::install()
# 1. Build openim-crontask
make build BINS=${SERVER_NAME}
- openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
- openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}"
# 2. Generate and install the openim-crontask configuration file (openim-crontask.yaml)
- echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
- openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/config.yaml"
# 3. Create and install the ${SERVER_NAME} systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}"
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
# 4. Start the openim-crontask service
@@ -104,7 +102,7 @@ function openim::crontask::uninstall()
set +o errexit
openim::common::sudo "systemctl stop ${SERVER_NAME}"
openim::common::sudo "systemctl disable ${SERVER_NAME}"
- openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
set -o errexit
@@ -115,15 +113,11 @@ function openim::crontask::uninstall()
function openim::crontask::status()
{
# Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully.
- systemctl status ${SERVER_NAME}|grep -q 'active' || {
+ if systemctl is-active --quiet "${SERVER_NAME}"; then
+ openim::log::info "${SERVER_NAME} is running successfully."
+ else
openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly"
return 1
- }
-
- # The listening port is hardcode in the configuration file
- if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then
- openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup"
- return 1
fi
}
diff --git a/scripts/install/openim-man.sh b/scripts/install/openim-man.sh
index 4cf8e385d..6dda4bfe1 100755
--- a/scripts/install/openim-man.sh
+++ b/scripts/install/openim-man.sh
@@ -48,7 +48,7 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
function openim::man::info() {
cat <<- EOF
Usage:
- man openim-server # Display the man page for openim-server
+ man openim-server to see openim-server help # Display the man page for openim-server
EOF
}
diff --git a/scripts/install/openim-msggateway.sh b/scripts/install/openim-msggateway.sh
index 612b7ae16..79aa6fa15 100755
--- a/scripts/install/openim-msggateway.sh
+++ b/scripts/install/openim-msggateway.sh
@@ -74,7 +74,7 @@ SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service"
# Print the necessary information after installation
function openim::msggateway::info() {
cat << EOF
-openim-msggateway listen on: ${OPENIM_MSGGATEWAY_HOST}
+openim-msggateway listen on: ${OPENIM_MSGGATEWAY_HOST}:${OPENIM_MESSAGE_GATEWAY_PORT}
EOF
}
@@ -85,18 +85,15 @@ function openim::msggateway::install()
# 1. Build openim-msggateway
make build BINS=${SERVER_NAME}
- openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
-
- openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
# 2. Generate and install the openim-msggateway configuration file (openim-msggateway.yaml)
- echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
- openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ # nono
# 3. Create and install the ${SERVER_NAME} systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}"
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
# 4. Start the openim-msggateway service
@@ -117,7 +114,7 @@ function openim::msggateway::uninstall()
set +o errexit
openim::common::sudo "systemctl stop ${SERVER_NAME}"
openim::common::sudo "systemctl disable ${SERVER_NAME}"
- openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
set -o errexit
@@ -134,7 +131,7 @@ function openim::msggateway::status()
}
# The listening port is hardcode in the configuration file
- if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then
+ if echo | telnet ${OPENIM_MSGGATEWAY_HOST} ${OPENIM_MESSAGE_GATEWAY_PORT} 2>&1|grep refused &>/dev/null;then
openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup"
return 1
fi
diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh
index 51ac78850..b28ca7efa 100755
--- a/scripts/install/openim-msgtransfer.sh
+++ b/scripts/install/openim-msgtransfer.sh
@@ -95,18 +95,18 @@ function openim::msgtransfer::install()
# 1. Build openim-msgtransfer
make build BINS=${SERVER_NAME}
- openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
+
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}"
openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
# 2. Generate and install the openim-msgtransfer configuration file (openim-msgtransfer.yaml)
- echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
- openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ # nono
# 3. Create and install the ${SERVER_NAME} systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}"
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
# 4. Start the openim-msgtransfer service
@@ -127,7 +127,7 @@ function openim::msgtransfer::uninstall()
set +o errexit
openim::common::sudo "systemctl stop ${SERVER_NAME}"
openim::common::sudo "systemctl disable ${SERVER_NAME}"
- openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
set -o errexit
@@ -138,15 +138,11 @@ function openim::msgtransfer::uninstall()
function openim::msgtransfer::status()
{
# Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully.
- systemctl status ${SERVER_NAME}|grep -q 'active' || {
+ if systemctl is-active --quiet "${SERVER_NAME}"; then
+ openim::log::info "${SERVER_NAME} is running successfully."
+ else
openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly"
return 1
- }
-
- # The listening port is hardcode in the configuration file
- if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then
- openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup"
- return 1
fi
}
diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh
index 9b1d4d53f..5197c9948 100755
--- a/scripts/install/openim-push.sh
+++ b/scripts/install/openim-push.sh
@@ -83,7 +83,7 @@ SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service"
# Print the necessary information after installation
function openim::push::info() {
cat << EOF
-openim-push listen on: ${OPENIM_PUSH_HOST}
+openim-push listen on: ${OPENIM_PUSH_HOST}:${OPENIM_PUSH_PORT}
EOF
}
@@ -94,18 +94,15 @@ function openim::push::install()
# 1. Build openim-push
make build BINS=${SERVER_NAME}
- openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}"
- openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
-
- # 2. Generate and install the openim-push configuration file (openim-push.yaml)
- echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
- openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ # 2. Generate and install the openim-push configuration file (config)
+ openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/config.yaml"
# 3. Create and install the ${SERVER_NAME} systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}"
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
# 4. Start the openim-push service
@@ -125,7 +122,7 @@ function openim::push::uninstall()
set +o errexit
openim::common::sudo "systemctl stop ${SERVER_NAME}"
openim::common::sudo "systemctl disable ${SERVER_NAME}"
- openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
set -o errexit
@@ -142,7 +139,7 @@ function openim::push::status()
}
# The listening port is hardcode in the configuration file
- if echo | telnet 127.0.0.1 7071 2>&1|grep refused &>/dev/null;then # Assuming a different port for push
+ if echo | telnet ${OPENIM_MSGGATEWAY_HOST} ${OPENIM_PUSH_PORT} 2>&1|grep refused &>/dev/null;then # Assuming a different port for push
openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup"
return 1
fi
diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh
index a0a7868f1..d6000b093 100755
--- a/scripts/install/openim-rpc.sh
+++ b/scripts/install/openim-rpc.sh
@@ -160,26 +160,86 @@ function openim::rpc::start_service() {
}
###################################### Linux Systemd ######################################
-SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service"
-
-function openim::rpc::install() {
- openim::log::info "Installing ${SERVER_NAME} ..."
+declare -A SYSTEM_FILE_PATHS
+for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ SYSTEM_FILE_PATHS["$service"]="/etc/systemd/system/${service}.service"
+done
+
+# Print the necessary information after installation
+function openim::rpc::info() {
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ echo "${service} listen on: ${OPENIM_RPC_PORT_LISTARIES[@]}"
+ done
}
-function openim::rpc::uninstall() {
- openim::log::info "Uninstalling ${SERVER_NAME} ..."
+# install openim-rpc
+function openim::rpc::install()
+{
+ pushd "${OPENIM_ROOT}"
-}
+ # 1. Build openim-rpc
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ make build BINS=${service}
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${service} ${OPENIM_INSTALL_DIR}/${service}"
+ openim::log::status "${service} binary: ${OPENIM_INSTALL_DIR}/${service}/${service}"
+ done
-function openim::rpc::status() {
- openim::log::info "Checking ${SERVER_NAME} status ..."
+ # 2. Generate and install the openim-rpc configuration file (config)
+ openim::log::status "openim-rpc config file: ${OPENIM_CONFIG_DIR}/config.yaml"
- openim::util::check_ports ${OPENIM_RPC_PORT_TARGETS[@]}
- # openim::util::check_ports ${OPENIM_RPC_PROM_PORT_TARGETS[@]}
+ # 3. Create and install the systemd unit files
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ echo ${LINUX_PASSWORD} | sudo -S bash -c \
+ "SERVER_NAME=${service} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATHS[$service]}"
+ openim::log::status "${service} systemd file: ${SYSTEM_FILE_PATHS[$service]}"
+ done
- openim::util::check_process_names ${SERVER_NAME}
+ # 4. Start the openim-rpc services
+ openim::common::sudo "systemctl daemon-reload"
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ openim::common::sudo "systemctl restart ${service}"
+ openim::common::sudo "systemctl enable ${service}"
+ done
+ openim::rpc::status || return 1
+ openim::rpc::info
+
+ openim::log::info "install openim-rpc successfully"
+ popd
+}
+
+# Unload
+function openim::rpc::uninstall()
+{
+ set +o errexit
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ openim::common::sudo "systemctl stop ${service}"
+ openim::common::sudo "systemctl disable ${service}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${service}"
+ openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${service}.yaml"
+ openim::common::sudo "rm -f ${SYSTEM_FILE_PATHS[$service]}"
+ done
+ set -o errexit
+ openim::log::info "uninstall openim-rpc successfully"
+}
+
+# Status Check
+function openim::rpc::status()
+{
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ # Check the running status of the ${service}. If active (running) is displayed, the ${service} is started successfully.
+ systemctl status ${service}|grep -q 'active' || {
+ openim::log::error "${service} failed to start, maybe not installed properly"
+ return 1
+ }
+
+ # The listening port is hardcoded in the configuration file
+ if echo | telnet ${OPENIM_MSGGATEWAY_HOST} ${OPENIM_RPC_PORT_LISTARIES[@]} 2>&1|grep refused &>/dev/null;then
+ openim::log::error "cannot access health check port, ${service} maybe not startup"
+ return 1
+ fi
+ done
}
if [[ "$*" =~ openim::rpc:: ]];then
- eval $*
-fi
\ No newline at end of file
+ eval $*
+fi
diff --git a/scripts/install/vimrc b/scripts/install/vimrc
deleted file mode 100644
index b128951c6..000000000
--- a/scripts/install/vimrc
+++ /dev/null
@@ -1,300 +0,0 @@
-" learn: https://github.com/cubxxw/awesome-cs-course/tree/master/linux
-" Read: https://github.com/cubxxw/awesome-cs-course/blob/master/linux/markdown/my_vim.md
-
-"vim的配置关于鼠标滚动滑动"""
-if has("autocmd")
- au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
- set mouse=a
-endif
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"C,C++ 按F5编译运行
-map :call CompileRunGcc()
-func! CompileRunGcc()
- exec "w"
- if &filetype == 'c'
- exec "!g++ % -o %<"
- exec "! ./%<"
- elseif &filetype == 'cpp'
- exec "!g++ % -o %<"
- exec "! ./%<"
- elseif &filetype == 'java'
- exec "!javac %"
- exec "!java %<"
- elseif &filetype == 'sh'
- :!./%
- endif
-endfunc
-"配置命令"
-"C,C++的调试
-"''''''''''''''''""""""""""""""""""""""""""""""""""'''''''''''''''''''''
-map :call Rungdb()
-func! Rungdb()
- exec "w"
- exec "!g++ % -g -o %<"
- exec "!gdb ./%<"
-endfunc
-
-""实用设置
-" 设置当文件被改动时自动载入
-set autoread
-" quickfix模式
-autocmd FileType c,cpp map :w:make
-"代码补全
-set completeopt=preview,menu
-
-" common configure
-"set noswapfile
-set mouse=a " 激活鼠标使用
-set wrap " 自动换行
-set sw=4 " 设置软宽度
-set gdefault " 行内替换
-set nu
-set showmatch " 高亮显示括号匹配
-set expandtab " 使用空格来替换 Tab
-set tabstop=4 " 设置 Tab 长度为 4 空格
-set shiftwidth=4 " 设置自动缩进长度为 4 空格
-set autoindent " 继承前一行的缩进方式,适用于多行注释"
-set autowrite " 自动保存
-set nocompatible " 关闭 vi 兼容模式
-set history=1000 " 设置历史记录步数
-set confirm " 在处理未保存或只读文件时,弹出确认
-
-" 搜索逐字符高亮
-set hlsearch
-set incsearch
-
-" 从不备份
-set nobackup
-set noswapfile
-
-let g:indentLine_enabled=0
-
-" golang configure ====> start
-let g:go_highlight_methods = 1
-let g:go_highlight_operators = 1
-let g:go_highlight_build_constraints = 1
-let g:go_fmt_autosave = 1
-let g:go_version_warning = 1
-let g:go_autodetect_gopath = 1
-let g:go_highlight_types = 1
-let g:go_highlight_fields = 1
-let g:go_highlight_functions = 1
-let g:go_highlight_function_calls = 1
-let g:go_highlight_extra_types = 1
-let g:go_highlight_generate_tags = 1
-let g:go_def_mode = 'gopls'
-let g:go_gopls_enabled = 1
-let g:go_guru_enabled = 1
-let g:go_fmt_experimental = 1
-let g:go_def_mapping_enabled = 1
-let g:go_build_tags = '-v'
-let g:go_fmt_command = "goimports"
-let g:go_list_type = "quickfix"
-let g:go_def_mapping_enable = 1
-
-map <2-LeftMouse> :GoDef
-map :GoDefPop
-map :GoCallers
-map :GoCallees
-map
-map
-unmap
-map :GoDef
-map :GoDefPop
-map :GoDoc
-map :GoInfo
-map :GoDefType
-map :GoAddTag
-map :GoImplements
-map :GoRename
-map :GoFillStruct
-map :GoCallers
-map :GoSameIdsToggle
-
-augroup go
- autocmd!
-
- " Show by default 4 spaces for a tab
- autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
-
- " :GoDef but opens in a vertical split
- autocmd FileType go nmap v (go-def-vertical)
- " :GoDef but opens in a horizontal split
- autocmd FileType go nmap s (go-def-split)
-
- " :GoAlternate commands :A, :AV, :AS and :AT
- autocmd Filetype go command! -bang A call go#alternate#Switch(0, 'edit')
- autocmd Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit')
- autocmd Filetype go command! -bang AS call go#alternate#Switch(0, 'split')
- autocmd Filetype go command! -bang AT call go#alternate#Switch(0, 'tabe')
-augroup END
-
-" build_go_files is a custom function that builds or compiles the test file.
-" It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test file
-function! s:build_go_files()
- let l:file = expand('%')
- if l:file =~# '^\f\+_test\.go$'
- call go#test#Test(0, 1)
- elseif l:file =~# '^\f\+\.go$'
- call go#cmd#Build(0)
- endif
-endfunction
-" golang configure ====> end
-
-:inoremap ( ()i
-:inoremap ) =ClosePair(')')
-:inoremap { {}O
-:inoremap } =ClosePair('}')
-:inoremap [ []i
-:inoremap ] =ClosePair(']')
-:inoremap " ""i
-:inoremap ' ''i
-function! ClosePair(char)
- if getline('.')[col('.') - 1] == a:char
- return "\"
- else
- return a:char
- endif
-endfunction
-filetype plugin indent on
-"打开文件类型检测, 加了这句才可以用智能补全
-
-set completeopt=longest,menu
-
-"""""""""""""""""""""""""""""""""""""""""""""""
- noremap :set nu
- noremap :!python3 a
- noremap :set ai
- noremap :syntax on
- set cursorline " 突出显示当前行
- set magic " 设置魔术
- "" noremap :! g++ -o a
-nnoremap
-nnoremap
-nnoremap
-nnoremap
-nmap wj :resize -3
-nmap wk :resize +3
-nmap wh :vertical resize -3
-nmap wl :vertical resize +3
-set guifont=Droid\ Sans\ Mono\ Nerd\ Font\ Complete:h18 " 设置字体
-set guicursor=n-v-c:ver5 " 设置光标为竖线
-set number ""# 显示行号
-set autowrite "" # 自动保存
-set ruler ""# 显示打开状态栏标尺
-set cursorline "" # 突出显示当前行
-
-set showmatch "" # 匹配光标所经过的括号等.
-set showcmd ""# 命令行显示输入的命令
-set showmode ""命令行显示vim当前模式
-set showtabline=0 " 隐藏Tab栏
-set laststatus=2 """"'vim 窗口底部显示永久状态栏,显示文件名,行号,列号等.
-let mapleader = "," " 定义键
-set nocompatible " 设置不兼容原始vi模式
-filetype on " 设置开启文件类型侦测
-filetype plugin on " 设置加载对应文件类型的插件
-set noeb " 关闭错误的提示
-syntax enable " 开启语法高亮功能
-syntax on " 自动语法高亮
-set cmdheight=2 " 设置命令行的高度
-set showcmd " select模式下显示选中的行数
-set ruler " 总是显示光标位置
-set laststatus=2 " 总是显示状态栏
-set number " 开启行号显示
-set cursorline " 高亮显示当前行
-set whichwrap+=<,>,h,l " 设置光标键跨行
-set ttimeoutlen=0 " 设置键响应时间
-set virtualedit=block,onemore " 允许光标出现在最后一个字符的后面
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 代码缩进和排版
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set autoindent " 设置自动缩进
-set cindent " 设置使用C/C++语言的自动缩进方式
-set cinoptions=g0,:0,N-s,(0 " 设置C/C++语言的具体缩进方式
-set smartindent " 智能的选择对其方式
-filetype indent on " 自适应不同语言的智能缩进
-set expandtab " 将制表符扩展为空格
-set tabstop=4 " 设置编辑时制表符占用空格数
-set shiftwidth=4 " 设置格式化时制表符占用空格数
-set softtabstop=4 " 设置4个空格为制表符
-set smarttab " 在行和段开始处使用制表符
-set nowrap " 禁止折行
-set backspace=2 " 使用回车键正常处理indent,eol,start等
-set sidescroll=10 " 设置向右滚动字符数
-set nofoldenable " 禁用折叠代码
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 代码补全
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set wildmenu " vim自身命名行模式智能补全
-set completeopt-=preview " 补全时不显示窗口,只显示补全列表
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 搜索设置
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set hlsearch " 高亮显示搜索结果
-set incsearch " 开启实时搜索功能
-set ignorecase " 搜索时大小写不敏感
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 缓存设置
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set nobackup " 设置不备份
-set noswapfile " 禁止生成临时文件
-set autoread " 文件在vim之外修改过,自动重新读入
-set autowrite " 设置自动保存
-set confirm " 在处理未保存或只读文件的时候,弹出确认
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"调整窗
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-nmap wj :resize -3
-nmap wk :resize +3
-nmap wh :vertical resize -3
-nmap wl :vertical resize +3
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"编码"
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set langmenu=zh_CN.UTF-8
-set helplang=cn
-set termencoding=utf-8
-set encoding=utf8
-set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"代码补全“
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-inoremap ' ''i
-inoremap " ""i
-inoremap ( ()i
-inoremap [ []i
-inoremap { {}O
- : set nu
- : set ai
- : syntax on
- : filetype on
- set tabstop=4
- set ignorecase
-noremap h
-noremap j
-noremap r
-noremap l
-" Specify a directory for plugins
-" - For Neovim: stdpath('data') . '/plugged'
-" - Avoid using standard Vim directory names like 'plugin'
-let g:coc_disable_startup_warning = 1
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"tmux"
-"复用终端、分屏"
-"let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-map h (easymotion-linebackward)
-map j (easymotion-j)
-map k (easymotion-k)
-map l (easymotion-lineforward)
-" 重复上一次操作, 类似repeat插件, 很强大
-map . (easymotion-repeat)
-nmap s (easymotion-s)
diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh
index d7c274c56..6fd9a5cfd 100755
--- a/scripts/lib/util.sh
+++ b/scripts/lib/util.sh
@@ -268,6 +268,7 @@ openim::util::check_docker_and_compose_versions() {
# Check if the docker compose sub-command is available
if ! docker compose version &> /dev/null; then
echo "Docker does not support the docker compose sub-command"
+ echo "You need to upgrade Docker to the right version"
return 1
fi
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index cc2c98544..29f527028 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -137,6 +137,7 @@ ifneq ($(shell $(GO) version | grep -q -E '\bgo($(GO_SUPPORTED_VERSIONS))\b' &&
endif
## go.build.%: Build binaries for a specific platform
+# CGO_ENABLED=0 https://wiki.musl-libc.org/functional-differences-from-glibc.html
.PHONY: go.build.%
go.build.%:
$(eval COMMAND := $(word 2,$(subst ., ,$*)))
diff --git a/scripts/make-rules/image.mk b/scripts/make-rules/image.mk
index 09e92126b..fa7f8ee9c 100644
--- a/scripts/make-rules/image.mk
+++ b/scripts/make-rules/image.mk
@@ -23,7 +23,8 @@
DOCKER := docker
# read: https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md
-REGISTRY_PREFIX ?= ghcr.io/openimsdk
+REGISTRY_PREFIX ?= registry.cn-hangzhou.aliyuncs.com/openimsdk
+# REGISTRY_PREFIX ?= ghcr.io/openimsdk
BASE_IMAGE ?= ghcr.io/openim-sigs/openim-bash-image
@@ -43,6 +44,7 @@ endif
# Determine image files by looking into build/images/*/Dockerfile
IMAGES_DIR ?= $(wildcard ${ROOT_DIR}/build/images/*)
# Determine images names by stripping out the dir names, and filter out the undesired directories
+# IMAGES ?= $(filter-out Dockerfile,$(foreach image,${IMAGES_DIR},$(notdir ${image})))
IMAGES ?= $(filter-out Dockerfile openim-tools openim-cmdutils,$(foreach image,${IMAGES_DIR},$(notdir ${image})))
ifeq (${IMAGES},)
@@ -105,6 +107,7 @@ image.build.%: go.build.%
| sed "s#BINARY_NAME#$(IMAGE)#g" >$(TMP_DIR)/$(IMAGE)/Dockerfile
@cp $(BIN_DIR)/platforms/$(IMAGE_PLAT)/$(IMAGE) $(TMP_DIR)/$(IMAGE)
$(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE))
+ @echo $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX)
@if [ $(shell $(GO) env GOARCH) != $(ARCH) ] ; then \
$(MAKE) image.daemon.verify ;\
$(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) ; \
diff --git a/scripts/template/head.md.tmpl b/scripts/template/head.md.tmpl
index 4aba97556..41dac30ef 100644
--- a/scripts/template/head.md.tmpl
+++ b/scripts/template/head.md.tmpl
@@ -16,7 +16,7 @@ Learn more about versions of OpenIM:
-
+
diff --git a/scripts/update-generated-docs.sh b/scripts/update-generated-docs.sh
index bd2ebb268..008cf63ed 100755
--- a/scripts/update-generated-docs.sh
+++ b/scripts/update-generated-docs.sh
@@ -28,10 +28,10 @@ source "${OPENIM_ROOT}/hack/lib/init.sh"
openim::golang::setup_env
BINS=(
- cmd/gendocs
- cmd/genopenimdocs
- cmd/genman
- cmd/genyaml
+ gendocs
+ genopenimdocs
+ genman
+ genyaml
)
make -C "${OPENIM_ROOT}" WHAT="${BINS[*]}"
diff --git a/tools/infra/go.mod b/tools/infra/go.mod
index a6cf16c77..8c66e2654 100644
--- a/tools/infra/go.mod
+++ b/tools/infra/go.mod
@@ -1,3 +1,11 @@
module github.com/openimsdk/open-im-server/v3/tools/infra
go 1.19
+
+require github.com/fatih/color v1.15.0
+
+require (
+ github.com/mattn/go-colorable v0.1.13 // indirect
+ github.com/mattn/go-isatty v0.0.17 // indirect
+ golang.org/x/sys v0.6.0 // indirect
+)
diff --git a/tools/infra/go.sum b/tools/infra/go.sum
new file mode 100644
index 000000000..2624c9db0
--- /dev/null
+++ b/tools/infra/go.sum
@@ -0,0 +1,10 @@
+github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
+github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
+github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
+github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
+github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
+github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/tools/infra/infra.go b/tools/infra/infra.go
index cc20a17c7..f8d8c7522 100644
--- a/tools/infra/infra.go
+++ b/tools/infra/infra.go
@@ -1,29 +1,25 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
package main
import (
"fmt"
- "log"
+
+ "github.com/fatih/color"
)
+// 定义一个函数以打印重要的链接信息
+func printLinks() {
+ blue := color.New(color.FgBlue).SprintFunc()
+ fmt.Printf("OpenIM Github: %s\n", blue("https://github.com/OpenIMSDK/Open-IM-Server"))
+ fmt.Printf("Slack Invitation: %s\n", blue("https://openimsdk.slack.com"))
+}
+
func main() {
- log.Println("Current module is still under development.")
- message := `
-Current module is still under development.
+ yellow := color.New(color.FgYellow)
+ blue := color.New(color.FgBlue, color.Bold)
+
+ yellow.Println("Current module is still under development.")
+ message := `
____ _____ __ __
/ __ \ |_ _|| \/ |
| | | | _ __ ___ _ __ | | | \ / |
@@ -36,5 +32,6 @@ ____ _____ __ __
Keep checking for updates!
`
- fmt.Println(message)
+ blue.Println(message)
+ printLinks() // 调用函数以打印链接信息
}
diff --git a/tools/versionchecker/go.mod b/tools/versionchecker/go.mod
index 619bcdb5b..7c274fcf9 100644
--- a/tools/versionchecker/go.mod
+++ b/tools/versionchecker/go.mod
@@ -1,3 +1,11 @@
module github.com/openimsdk/open-im-server/v3/tools/versionchecker
go 1.19
+
+require github.com/fatih/color v1.15.0
+
+require (
+ github.com/mattn/go-colorable v0.1.13 // indirect
+ github.com/mattn/go-isatty v0.0.17 // indirect
+ golang.org/x/sys v0.6.0 // indirect
+)
diff --git a/tools/versionchecker/go.sum b/tools/versionchecker/go.sum
new file mode 100644
index 000000000..2624c9db0
--- /dev/null
+++ b/tools/versionchecker/go.sum
@@ -0,0 +1,10 @@
+github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
+github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
+github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
+github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
+github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
+github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/tools/versionchecker/versionchecker.go b/tools/versionchecker/versionchecker.go
index e7bc3e379..12254b58e 100644
--- a/tools/versionchecker/versionchecker.go
+++ b/tools/versionchecker/versionchecker.go
@@ -20,9 +20,12 @@ import (
"os/exec"
"runtime"
"time"
+
+ "github.com/fatih/color"
+ //"github.com/openimsdk/open-im-server/v3/pkg/common/version"
)
-func executeCommand(cmdName string, args ...string) (string, error) {
+func ExecuteCommand(cmdName string, args ...string) (string, error) {
cmd := exec.Command(cmdName, args...)
var out bytes.Buffer
var stderr bytes.Buffer
@@ -31,19 +34,15 @@ func executeCommand(cmdName string, args ...string) (string, error) {
err := cmd.Run()
if err != nil {
- return "", fmt.Errorf("Error executing %s: %v", cmdName, err)
+ return "", fmt.Errorf("error executing %s: %v, stderr: %s", cmdName, err, stderr.String())
}
return out.String(), nil
}
func printTime() string {
currentTime := time.Now()
-
- // 使用 Format 函数以优雅的方式格式化日期和时间
- // 2006-01-02 15:04:05 是 Go 中的标准时间格式
formattedTime := currentTime.Format("2006-01-02 15:04:05")
-
- return fmt.Sprintf("Current Date & Time:", formattedTime)
+ return fmt.Sprintf("Current Date & Time: %s", formattedTime)
}
func getGoVersion() string {
@@ -54,7 +53,7 @@ func getGoVersion() string {
}
func getDockerVersion() string {
- version, err := executeCommand("docker", "--version")
+ version, err := ExecuteCommand("docker", "--version")
if err != nil {
return "Docker is not installed. Please install it to get the version."
}
@@ -62,7 +61,7 @@ func getDockerVersion() string {
}
func getDockerComposeVersion() string {
- version, err := executeCommand("docker-compose", "--version")
+ version, err := ExecuteCommand("docker-compose", "--version")
if err != nil {
return "Docker Compose is not installed. Please install it to get the version."
}
@@ -70,7 +69,7 @@ func getDockerComposeVersion() string {
}
func getKubernetesVersion() string {
- version, err := executeCommand("kubectl", "version", "--client", "--short")
+ version, err := ExecuteCommand("kubectl", "version", "--client", "--short")
if err != nil {
return "Kubernetes is not installed. Please install it to get the version."
}
@@ -78,38 +77,52 @@ func getKubernetesVersion() string {
}
func getGitVersion() string {
- version, err := executeCommand("git", "branch", "--show-current")
+ version, err := ExecuteCommand("git", "branch", "--show-current")
if err != nil {
return "Git is not installed. Please install it to get the version."
}
return version
}
-// NOTE: You'll need to provide appropriate commands for OpenIM versions.
-func getOpenIMServerVersion() string {
- // Placeholder
- return "OpenIM Server: v3.2"
-}
+// // NOTE: You'll need to provide appropriate commands for OpenIM versions.
+// func getOpenIMServerVersion() string {
+// // Placeholder
+// openimVersion := version.GetSingleVersion()
+// return "OpenIM Server: " + openimVersion + "\n"
+// }
-func getOpenIMClientVersion() string {
- // Placeholder
- return "OpenIM Client: v3.2"
-}
+// func getOpenIMClientVersion() (string, error) {
+// openIMClientVersion, err := version.GetClientVersion()
+// if err != nil {
+// return "", err
+// }
+// return "OpenIM Client: " + openIMClientVersion.ClientVersion + "\n", nil
+// }
func main() {
- fmt.Println(printTime())
- fmt.Println("# Diagnostic Tool Result\n")
- fmt.Println("## Go Version")
+ // red := color.New(color.FgRed).SprintFunc()
+ green := color.New(color.FgGreen).SprintFunc()
+ blue := color.New(color.FgBlue).SprintFunc()
+ yellow := color.New(color.FgYellow).SprintFunc()
+
+ fmt.Println(green(printTime()))
+ fmt.Println(yellow("# Diagnostic Tool Result\n"))
+ fmt.Println(blue("## Go Version"))
fmt.Println(getGoVersion())
- fmt.Println("## Branch Type")
+ fmt.Println(blue("## Branch Type"))
fmt.Println(getGitVersion())
- fmt.Println("## Docker Version")
+ fmt.Println(blue("## Docker Version"))
fmt.Println(getDockerVersion())
- fmt.Println("## Docker Compose Version")
+ fmt.Println(blue("## Docker Compose Version"))
fmt.Println(getDockerComposeVersion())
- fmt.Println("## Kubernetes Version")
+ fmt.Println(blue("## Kubernetes Version"))
fmt.Println(getKubernetesVersion())
- fmt.Println("## OpenIM Versions")
- fmt.Println(getOpenIMServerVersion())
- fmt.Println(getOpenIMClientVersion())
+ // fmt.Println(blue("## OpenIM Versions"))
+ // fmt.Println(getOpenIMServerVersion())
+ // clientVersion, err := getOpenIMClientVersion()
+ // if err != nil {
+ // fmt.Println(red("Error getting OpenIM Client Version: "), err)
+ // } else {
+ // fmt.Println(clientVersion)
+ // }
}