Merge branch 'openimsdk:main' into main

pull/2237/head
chao 5 months ago committed by GitHub
commit 20dfafd218
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,9 +5,8 @@
.git
# Ignore build artifacts
_output/
logs/
_output/
# Ignore non-essential documentation
README.md
README-zh_CN.md
@ -18,8 +17,6 @@ CHANGELOG/
# Ignore testing and linting configuration
.golangci.yml
# Ignore deployment-related files
docker-compose.yaml
# Ignore assets
assets/

13
.env

@ -0,0 +1,13 @@
MONGO_IMAGE=mongo:6.0.2
REDIS_IMAGE=redis:7.0.0
ZOOKEEPER_IMAGE=bitnami/zookeeper:3.8
KAFKA_IMAGE=bitnami/kafka:3.5.1
MINIO_IMAGE=minio/minio:RELEASE.2024-01-11T07-46-16Z
OPENIM_WEB_FRONT_IMAGE=ghcr.io/openimsdk/openim-web:v3.5.0-docker
OPENIM_ADMIN_FRONT_IMAGE=ghcr.io/openimsdk/openim-admin:toc-base-open-docker.35
DATA_DIR=./

1
.gitattributes vendored

@ -0,0 +1 @@
*.sh text eol=lf

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# https://github.com/marketplace/actions/code-language-detector
directory: ./
file_types:
- .go

@ -0,0 +1,50 @@
# https://github.com/marketplace/actions/conformity-checker-for-project
baseConfig:
searchDirectory: "./"
ignoreCase: false
directoryNaming:
allowHyphens: true
allowUnderscores: false
mustBeLowercase: true
fileNaming:
allowHyphens: true
allowUnderscores: true
mustBeLowercase: true
ignoreFormats:
- "\\.log$"
- "\\.env$"
- "README\\.md$"
- "_test\\.go$"
- "\\.md$"
- _test\\.txt$
- LICENSE
- Dockerfile
- CODEOWNERS
- Makefile
ignoreDirectories:
- "vendor"
- ".git"
- "deployments"
- "node_modules"
- "logs"
- "CHANGELOG"
- "components"
- "_output"
- "tools/openim-web"
- "CHANGELOG"
- "examples/Test_directory"
- test/testdata
fileTypeSpecificNaming:
".yaml":
allowHyphens: true
allowUnderscores: false
mustBeLowercase: true
".go":
allowHyphens: false
allowUnderscores: true
mustBeLowercase: true

@ -73,14 +73,22 @@ jobs:
- name: Docker Operations
run: |
sudo make init
sudo docker compose up -d
sudo bash bootstrap.sh
sudo mage
sudo sleep 20
- name: Module Operations
run: |
sudo make tidy
sudo make tools.verify.go-gitlint
sudo go mod tidy
echo "===========> Verifying go-gitlint is installed"
if [ ! -f ./_output/tools/go-gitlint ]; then
export GOBIN=$(pwd)/_output/tools
echo "===========> Installing The default installation path is /home/ubuntu/DF/open-im-server/_output/tools/go-gitlint"
sudo go install github.com/marmotedu/go-gitlint/cmd/go-gitlint@latest
echo "===========> go-gitlint is installed in /home/ubuntu/DF/open-im-server/_output/tools/go-gitlint"
fi
- name: Build, Start(make build && make start)
run: |
@ -90,7 +98,8 @@ jobs:
run: |
sudo ./scripts/install/install.sh -s
- name: Exec OpenIM API test (make test-api)
# - name: Exec OpenIM API test (make test-api)
- name: Exec OpenIM test (make test)
run: |
mkdir -p ./tmp
touch ./tmp/test.md
@ -98,23 +107,27 @@ jobs:
echo "## OpenIM API Test" >> ./tmp/test.md
echo "<details><summary>Command Output for OpenIM API Test</summary>" >> ./tmp/test.md
echo "<pre><code>" >> ./tmp/test.md
sudo make test-api | tee -a ./tmp/test.md
echo "===========> Run api test"
./scripts/install/test.sh
echo "===========> Run api test" >> ./tmp/test.md
./scripts/install/test.sh >> ./tmp/test.md
echo "</code></pre>" >> ./tmp/test.md
echo "</details>" >> ./tmp/test.md
sudo make test-api
echo "===========> Run api test"
./scripts/install/test.sh
- name: Exec OpenIM E2E Test (make test-e2e)
run: |
echo "" >> ./tmp/test.md
echo "## OpenIM E2E Test" >> ./tmp/test.md
echo "<details><summary>Command Output for OpenIM E2E Test</summary>" >> ./tmp/test.md
echo "<pre><code>" >> ./tmp/test.md
sudo make test-e2e | tee -a ./tmp/test.md
echo "</code></pre>" >> ./tmp/test.md
echo "</details>" >> ./tmp/test.md
# - name: Exec OpenIM E2E Test (make test-e2e)
# run: |
# echo "" >> ./tmp/test.md
# echo "## OpenIM E2E Test" >> ./tmp/test.md
# echo "<details><summary>Command Output for OpenIM E2E Test</summary>" >> ./tmp/test.md
# echo "<pre><code>" >> ./tmp/test.md
# sudo make test-e2e | tee -a ./tmp/test.md
# echo "</code></pre>" >> ./tmp/test.md
# echo "</details>" >> ./tmp/test.md
sudo make test-e2e
# sudo make test-e2e
- name: Comment PR with file
uses: thollander/actions-comment-pull-request@v2

@ -29,7 +29,13 @@ jobs:
go-version: '1.21'
cache: false
- name: OpenIM Scripts Verification(make verify)
run: sudo make verify
run: |
cd scripts
for script in verify-*; do
if [ -x "$script" ]; then
./"$script"
fi
done
- name: golangci-lint
uses: golangci/golangci-lint-action@v4.0.0
with:

@ -1,3 +1,4 @@
# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -11,8 +12,7 @@
# 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.
name: OpenIM CI Aotu Build and Install
name: OpenIM CI Auto Build
on:
push:
@ -37,14 +37,11 @@ on:
- "**.md"
- "docs/**"
env:
GO_VERSION: "1.19"
GOLANGCI_VERSION: "v1.50.1"
jobs:
openim:
name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
build-linux:
name: Execute OpenIM Script On Linux
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
@ -52,248 +49,142 @@ jobs:
name: openim
strategy:
matrix:
go_version: ["1.19","1.20","1.21"]
os: [ubuntu-latest]
steps:
- name: Setup
uses: actions/checkout@v4
arch: [arm64, armv7, amd64]
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go_version }}
id: go
steps:
- uses: actions/checkout@v3
- name: Install Task
uses: arduino/setup-task@v1
- name: Set up Go
uses: actions/setup-go@v4
with:
version: '3.x' # If available, use the latest major version that's compatible
repo-token: ${{ secrets.GITHUB_TOKEN }}
go-version: '1.21'
- name: Module Operations
- name: Set up Docker for Linux
run: |
sudo make tidy
sudo make tools.verify.go-gitlint
- name: Format Code
run: sudo make format
continue-on-error: true
- name: Generate Files
run: make gen
continue-on-error: true
- name: Build Source
run: sudo make build
- name: Build multiarch PLATFORMS
if: startsWith(github.ref, 'refs/heads/release-')
run: |
sudo make multiarch
- name: Cleanup Build
run: sudo make clean
sudo docker compose up -d
sudo sleep 30 # Increased sleep time for better stability
timeout-minutes: 20 # Increased timeout for Docker setup
- name: Set Current Directory
id: set_directory
run: echo "::set-output name=directory::$(pwd)"
continue-on-error: true
- name: Collect and Display Test Coverage
id: collect_coverage
run: |
cd ${{ steps.set_directory.outputs.directory }}
make cover
echo "::set-output name=coverage_file::./_output/tmp/coverage.out"
echo "Test Coverage:"
cat ${{ steps.collect_coverage.outputs.coverage_file }}
continue-on-error: true
- name: init
run: sudo bash bootstrap.sh
timeout-minutes: 20
openim-start:
name: Test OpenIM install/start on ${{ matrix.os }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
permissions:
contents: write
pull-requests: write
environment:
name: openim
strategy:
matrix:
go_version: ["1.21"]
os: ["ubuntu-latest"]
steps:
- name: Checkout and Install OpenIM
uses: actions/checkout@v4
- name: Install Task
uses: arduino/setup-task@v1
with:
version: '3.x' # If available, use the latest major version that's compatible
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run OpenIM make install start
- name: Build, Start, Check Services and Print Logs for Linux
run: |
sudo make install
sudo mage
sudo mage start
sudo mage check
# - name: Check the OpenIM environment and status
# run: |
# sudo docker images
# sudo docker ps
- name: Check the OpenIM environment and status
if: runner.os == 'Linux' && matrix.arch == 'amd64'
id: docker_info
- name: Restart Services and Print Logs
run: |
sleep 30
echo "images<<EOF" >> $GITHUB_ENV
sudo docker images >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "containers<<EOF" >> $GITHUB_ENV
sudo docker ps >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
if: runner.os == 'Linux' && matrix.arch == 'amd64'
with:
message: |
> [!TIP]
> Run make install to check the status
### Docker Images:
<details><summary>Click to expand docker images</summary>
```bash
${{ env.images }}
```
</details>
### Docker Processes:
<details><summary>Click to expand docker ps</summary>
```bash
${{ env.containers }}
```
</details>
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
execute-scripts:
name: Execute OpenIM Script On ${{ matrix.os }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
permissions:
contents: write
pull-requests: write
environment:
name: openim
strategy:
matrix:
go_version: ["1.21"]
os: ["ubuntu-latest", "macos-latest"]
arch: [arm64, armv7, amd64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go_version }}
id: go
sudo mage stop
sudo mage start
sudo mage check
# build-mac:
# name: Execute OpenIM Script On macOS
# runs-on: macos-latest
# permissions:
# contents: write
# pull-requests: write
# environment:
# name: openim
# strategy:
# matrix:
# arch: [arm64, armv7, amd64]
#
# steps:
# - uses: actions/checkout@v3
- name: Install Task
uses: arduino/setup-task@v1
with:
version: '3.x' # If available, use the latest major version that's compatible
repo-token: ${{ secrets.GITHUB_TOKEN }}
# - name: Set up Go
# uses: actions/setup-go@v4
# with:
# go-version: '1.21'
# - name: Install latest Bash (macOS only)
# if: runner.os == 'macOS' && matrix.arch == 'arm64'
# run: |
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# brew update
# brew install bash
# brew install gnu-sed
# while ! docker system info > /dev/null 2>&1; do
# echo "Waiting for Docker to start..."
# sleep 10 # Increased delay to ensure Docker starts properly
# done
# echo "/usr/local/bin" >> $GITHUB_PATH
# echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
# continue-on-error: true
- name: Set up Docker for Ubuntu
if: runner.os == 'Linux'
run: |
sudo make init
sudo docker compose up -d
sudo sleep 20
# - name: Set up Docker for macOS
# if: runner.os == 'macOS' && matrix.arch == 'arm64'
# - name: Install Docker
# run: |
# brew install --cask docker
# open /Applications/Docker.app
# brew install docker
# brew install docker-compose
# sleep 10
# docker-compose --version || brew install docker-compose
# docker-compose up -d
# sleep 20
# sleep 30
# timeout-minutes: 20
#
- name: Module Operations for Ubuntu
if: runner.os == 'Linux'
run: |
sudo make tidy
sudo make tools.verify.go-gitlint
# - name: init
# run: sudo bash bootstrap.sh
# timeout-minutes: 20
# - name: Module Operations for macOS
# if: runner.os == 'macOS'
# - name: Build, Start, Check Services and Print Logs for Linux
# run: |
# make tidy
# make tools.verify.go-gitlint
- name: Build, Start, Check Services and Print Logs for Ubuntu
if: runner.os == 'Linux'
run: |
sudo make build
sudo make start
sudo make check
- name: Restart Services and Print Logs for Ubuntu
if: runner.os == 'Linux' && matrix.arch == 'amd64'
run: |
sudo make restart
sudo make check
- name: Build, Start, Check Services and Print Logs for macOS
if: runner.os == 'macOS' && matrix.arch == 'arm64'
run: |
make build
# sudo mage
# sudo mage start
# sudo mage check
openim-test-build-image:
name: Build OpenIM Docker Image
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
environment:
name: openim
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go_version }}
id: go
# - name: Restart Services and Print Logs
# run: |
# sudo mage stop
# sudo mage start
# sudo mage check
# build-windows:
# name: Execute OpenIM Script On Windows
# runs-on: windows-latest
# permissions:
# contents: write
# pull-requests: write
# environment:
# name: openim
# strategy:
# matrix:
# arch: [arm64, armv7, amd64]
#
# steps:
# - uses: actions/checkout@v3
- name: Install Task
uses: arduino/setup-task@v1
with:
version: '3.x' # If available, use the latest major version that's compatible
repo-token: ${{ secrets.GITHUB_TOKEN }}
# - name: Set up Go
# uses: actions/setup-go@v4
# with:
# go-version: '1.21'
- name: Test Docker Build
run: |
sudo make init
sudo make image
# - name: Set up Docker for Windows
# run: |
# $images = @("zookeeper", "redis", "kafka")
# foreach ($image in $images) {
# $tag = "$image:latest"
# docker pull $tag | Out-Null
# if ($LASTEXITCODE -ne 0) {
# Write-Host "Skipping $image as it is not available for Windows"
# } else {
# Write-Host "Successfully pulled $image"
# }
# }
# docker compose up -d
# Start-Sleep -Seconds 30
# timeout-minutes: 20
# shell: pwsh
# - name: init
# run: bootstrap.bat
# timeout-minutes: 20
# - name: Build, Start, Check Services and Print Logs for Linux
# run: |
# mage
# mage start
# mage check
- name: Get OpenIM Docker Images Status
id: docker_processes
run: |
sudo docker images
sudo docker ps
# - name: Restart Services and Print Logs
# run: |
# mage stop
# mage start
# mage check

@ -56,7 +56,8 @@ jobs:
- name: Generate all necessary files, such as error code files
run: |
make generate
make gen.docgo.doc
make gen
echo "Generate all necessary files successfully"
continue-on-error: true
@ -68,9 +69,9 @@ jobs:
echo "Generate all necessary files successfully"
continue-on-error: true
- name: Generate Vertions
- name: Generate Versions Including Pre-release Identifiers
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo $latest_tag > pkg/common/config/version
continue-on-error: true

1
.gitignore vendored

@ -34,7 +34,6 @@ deployments/charts/generated-configs/
### OpenIM Config ###
.env
config/config.yaml
config/openim.yaml
config/alertmanager.yml
config/prometheus.yml
config/email.tmpl

@ -39,19 +39,19 @@ run:
# from this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
- components
- docs
- util
- .*~
- api/swagger/docs
- server/docs
- components/mnt/config/certs
- logs
# skip-dirs:
# - components
# - docs
# - util
# - .*~
# - api/swagger/docs
# - server/docs
# - components/mnt/config/certs
# - logs
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
# skip-dirs-use-default: true
# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
@ -59,15 +59,15 @@ run:
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-files:
- ".*\\.my\\.go$"
- _test.go
- ".*_test.go"
- "mocks/"
- ".github/"
- "logs/"
- "_output/"
- "components/"
# skip-files:
# - ".*\\.my\\.go$"
# - _test.go
# - ".*_test.go"
# - "mocks/"
# - ".github/"
# - "logs/"
# - "_output/"
# - "components/"
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
@ -87,7 +87,7 @@ run:
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
# format: colored-line-number
# print lines of code with issue, default is true
print-issued-lines: true
@ -118,8 +118,7 @@ linters-settings:
right-to-left-isolate: true
first-strong-isolate: true
pop-directional-isolate: true
# checks assignments with too many blank identifiers; default is 2
max-blank-identifiers: 2
dupl:
# tokens count to trigger issue, 150 by default
threshold: 200
@ -151,6 +150,11 @@ linters-settings:
comparison: true
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map
# check switch statements in generated files also
check-generated: false
# indicates that switch statements are to be considered exhaustive if a
@ -162,33 +166,34 @@ linters-settings:
ignore-enum-members: ""
# consider enums only in package scopes, not in inner scopes
package-scope-only: false
exhaustivestruct:
struct-patterns:
- '*.Test'
- '*.Test2'
- '*.Embedded'
- '*.External'
# forbidigo:
forbidigo:
# # Forbid the following identifiers (identifiers are written using regexp):
# forbid:
forbid:
# - ^print.*$
# - 'fmt\.Print.*'
# - fmt.Println.* # too much log noise
- 'fmt\.Print.*'
- fmt.Println.* # too much log noise
- ^unsafe\..*$
- ^init$
- ^os.Exit$
- ^fmt.Print.*$
- errors.New.*$
- ^fmt.Println.*$
- ^panic$
- painc
# - ginkgo\\.F.* # these are used just for local development
# # Exclude godoc examples from forbidigo checks. Default is true.
# exclude_godoc_examples: false
funlen:
lines: 150
lines: 220
statements: 80
gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
prefix: github.com/openimsdk/open-im-server
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30
goconst:
# minimal length of string constant, 3 by default
min-len: 3
@ -214,9 +219,6 @@ linters-settings:
# By default list of stable checks is used.
enabled-checks:
#- rangeValCopy
- nestingreduce
- truncatecmp
- unnamedresult
- ruleguard
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
@ -245,9 +247,6 @@ linters-settings:
hugeParam:
# size in bytes that makes the warning trigger (default 80)
sizeThreshold: 80
nestingReduce:
# min number of statements inside a branch to trigger a warning (default 5)
bodyWidth: 5
rangeExprCopy:
# size in bytes that makes the warning trigger (default 512)
sizeThreshold: 512
@ -261,15 +260,10 @@ linters-settings:
ruleguard:
# path to a gorules file for the ruleguard checker
rules: ''
truncateCmp:
# whether to skip int/uint/uintptr types (default true)
skipArchDependent: true
underef:
# whether to skip (*x).method() calls where x is a pointer receiver (default true)
skipRecvDeref: true
unnamedResult:
# whether to check exported functions
checkExported: true
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30
@ -286,9 +280,12 @@ linters-settings:
# list of regexps for excluding particular comment lines from check
exclude:
# example: exclude comments which contain numbers
# - '[0-9]+'
- '[0-9]+'
- 'func\s+\w+'
- 'FIXME:'
- '.*func.*'
# check that each sentence starts with a capital letter
capital: false
capital: true
godox:
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
# might be left in the code accidentally and should be resolved before merging
@ -311,15 +308,15 @@ linters-settings:
# by default
extra-rules: false
goheader:
values:
const:
# goheader:
# values:
# const:
# define here const type values in format k:v, for example:
# COMPANY: MY COMPANY
regexp:
# regexp:
# define here regexp type values, for example
# AUTHOR: .*@mycompany\.com
template: # |-
# template: # |-
# put here copyright header template for source code files, for example:
# Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time.
#
@ -337,21 +334,45 @@ linters-settings:
# 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.
template-path:
# template-path:
# also as alternative of directive 'template' you may put the path to file with the template source
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/openimsdk/open-im-server
gomnd:
settings:
mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: argument,case,condition,operation,return,assign
# ignored-numbers: 1000
# ignored-files: magic_.*.go
# ignored-functions: math.*
# List of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
# Default: ["argument", "case", "condition", "operation", "return", "assign"]
checks:
- argument
- case
- condition
- operation
- return
- assign
# List of numbers to exclude from analysis.
# The numbers should be written as string.
# Values always ignored: "1", "1.0", "0" and "0.0"
# Default: []
ignored-numbers:
- '0666'
- '0755'
- '42'
# List of file patterns to exclude from analysis.
# Values always ignored: `.+_test.go`
# Default: []
ignored-files:
- 'magic1_.+\.go$'
# List of function patterns to exclude from analysis.
# Following functions are always ignored: `time.Date`,
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
# `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`.
# Default: []
ignored-functions:
- '^math\.'
- '^webhook\.StatusText$'
gomoddirectives:
# Allow local `replace` directives. Default is false.
replace-local: true
@ -363,6 +384,7 @@ linters-settings:
retract-allow-no-explanation: false
# Forbid the use of the `exclude` directives. Default is false.
exclude-forbidden: false
gomodguard:
allowed:
modules:
@ -426,9 +448,6 @@ linters-settings:
checks: [ "all" ]
govet:
# report about shadowed variables
check-shadowing: false
# settings per analyzer
settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers
@ -445,15 +464,25 @@ linters-settings:
disable:
- shadow
disable-all: false
# depguard:
# list-type: blacklist
# include-go-root: false
# packages:
# - github.com/Sirupsen/logrus
# packages-with-error-message:
# # specify an error message to output when a blacklisted package is used
# - github.com/Sirupsen/logrus: "logging is allowed only by logutils.Log"
depguard:
rules:
prevent_unmaintained_packages:
list-mode: lax # allow unless explicitely denied
files:
- $all
- "!$test"
allow:
- $gostd
deny:
- pkg: io/ioutil
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
- pkg: github.com/OpenIMSDK
desc: "The OpenIM organization has been replaced with lowercase, please do not use uppercase organization name, you will use openimsdk"
- pkg: log
desc: "We have a wrapped log package at openim, we recommend you to use our wrapped log package, https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/logging.md"
- pkg: errors
desc: "We have a wrapped errors package at openim, we recommend you to use our wrapped errors package, https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/error-code.md"
importas:
# if set to `true`, force to use alias.
@ -463,6 +492,8 @@ linters-settings:
# using `servingv1` alias for `knative.dev/serving/pkg/apis/serving/v1` package
- pkg: knative.dev/serving/pkg/apis/serving/v1
alias: servingv1
- pkg: gopkg.in/yaml.v2
alias: yaml
# using `autoscalingv1alpha1` alias for `knative.dev/serving/pkg/apis/autoscaling/v1alpha1` package
- pkg: knative.dev/serving/pkg/apis/autoscaling/v1alpha1
alias: autoscalingv1alpha1
@ -471,8 +502,6 @@ linters-settings:
# see https://github.com/julz/importas#use-regular-expression for details
- pkg: knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)
alias: $1$2
# using `jwt` alias for `github.com/appleboy/gin-jwt/v2` package
jwt: github.com/appleboy/gin-jwt/v2
ireturn:
# ireturn allows using `allow` and `reject` settings at the same time.
@ -503,9 +532,6 @@ linters-settings:
line-length: 250
# tab width in spaces. Default to 1.
tab-width: 4
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
@ -538,8 +564,6 @@ linters-settings:
nolintlint:
# Disable to ensure that all nolint directives actually have an effect. Default is true.
allow-unused: false
# Disable to ensure that nolint directives don't have a leading space. Default is true.
allow-leading-space: true
# Exclude following linters from requiring an explanation. Default is [].
allow-no-explanation: [ ]
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
@ -563,14 +587,13 @@ linters-settings:
strict: false
# Please refer to https://github.com/yeya24/promlinter#usage for detailed usage.
disabled-linters:
# - "Help"
# - "MetricUnits"
# - "Counter"
# - "HistogramSummaryReserved"
# - "MetricTypeInName"
# - "ReservedChars"
# - "CamelCase"
# - "lintUnitAbbreviations"
- "Help"
- "MetricUnits"
- "Counter"
- "HistogramSummaryReserved"
- "MetricTypeInName"
- "ReservedChars"
- "CamelCase"
predeclared:
# comma-separated list of predeclared identifiers to not report on
@ -580,6 +603,7 @@ linters-settings:
rowserrcheck:
packages:
- github.com/jmoiron/sqlx
revive:
# see https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: true
@ -587,15 +611,27 @@ linters-settings:
rules:
- name: indent-error-flow
severity: warning
- name: exported
severity: warning
- name: var-naming
arguments: [ [ "OpenIM"] ]
# arguments: [ ["ID", "HTTP", "URL", "URI", "API", "APIKey", "Token", "TokenID", "TokenSecret", "TokenKey", "TokenSecret", "JWT", "JWTToken", "JWTTokenID", "JWTTokenSecret", "JWTTokenKey", "JWTTokenSecret", "OAuth", "OAuthToken", "RPC" ] ]
- name: atomic
- name: line-length-limit
severity: error
arguments: [200]
- name: unhandled-error
arguments : ["fmt.Printf", "myFunction"]
staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.16"
go: "1.20"
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
stylecheck:
# Select the Go version to target. The default is '1.13'.
go: "1.16"
go: "1.20"
# https://staticcheck.io/docs/options#checks
checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ]
@ -607,7 +643,6 @@ linters-settings:
# https://staticcheck.io/docs/options#http_status_code_whitelist
http-status-code-whitelist: [ "200", "400", "404", "500" ]
tagliatelle:
# check the struck tag name case
case:
@ -653,12 +688,11 @@ linters-settings:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unused:
# unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
@ -672,6 +706,7 @@ linters-settings:
- errors.New(
- errors.Unwrap(
- .Wrap(
- .WrapMsg(
- .Wrapf(
- .WithMessage(
- .WithMessagef(
@ -679,6 +714,8 @@ linters-settings:
ignorePackageGlobs:
- encoding/*
- github.com/pkg/*
- github.com/openimsdk/*
- github.com/OpenIMSDK/*
wsl:
# If true append is only allowed to be cuddled if appending value is
@ -705,7 +742,6 @@ linters-settings:
# Allow only slices initialized with a length of zero. Default is false.
always: false
# The custom section can be used to define linter plugins to be loaded at runtime. See README doc
# for more info.
#custom:
@ -731,16 +767,21 @@ linters:
- errcheck
- decorder
- ineffassign
- forbidigo
- revive
- reassign
- tparallel
- unconvert
- fieldalignment
- dupl
- dupword
- errname
- gci
- goheader
- exhaustive
- gocritic
- goprintffuncname
- gomnd
- goconst
- gosec
- misspell # Spelling mistakes
- staticcheck # Static analysis
@ -761,6 +802,7 @@ issues:
exclude:
- tools/.*
- test/.*
- components/*
- third_party/.*
# Excluding configuration per-path, per-linter, per-text and per-source

@ -1,31 +1,49 @@
# Build Stage
FROM golang:1.20 AS builder
# Use Go 1.21 Alpine as the base image for building the application
FROM golang:1.21-alpine as builder
# Set go mod installation source and proxy
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
ENV GO111MODULE=$GO111MODULE
ENV GOPROXY=$GOPROXY
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set up the working directory
WORKDIR /openim/openim-server
# Set the Go proxy to improve dependency resolution speed
ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
# Copy all files to the container
ADD . .
RUN go mod download
RUN make clean
RUN make build
# Install Mage to use for building the application
RUN go install github.com/magefile/mage@v1.15.0
FROM ghcr.io/openim-sigs/openim-ubuntu-image:latest
# Optionally build your application if needed
RUN mage build
WORKDIR ${SERVER_WORKDIR}
# Using Alpine Linux with Go environment for the final image
FROM golang:1.21-alpine
# Copy scripts and binary files to the production image
COPY --from=builder ${OPENIM_SERVER_BINDIR} /openim/openim-server/_output/bin
COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
COPY --from=builder ${SERVER_WORKDIR}/deployments /openim/openim-server/deployments
# Install necessary packages, such as bash
RUN apk add --no-cache bash
CMD ["/openim/openim-server/scripts/docker-start-all.sh"]
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
COPY --from=builder /go/bin/mage /usr/local/bin/mage
COPY --from=builder $SERVER_DIR/magefile_windows.go $SERVER_DIR/
COPY --from=builder $SERVER_DIR/magefile_unix.go $SERVER_DIR/
COPY --from=builder $SERVER_DIR/magefile.go $SERVER_DIR/
COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/
RUN go get github.com/openimsdk/gomake@v0.0.9
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]

@ -1,255 +0,0 @@
# ==============================================================================
# define the default goal
#
.DEFAULT_GOAL := help
## all: Run tidy, gen, add-copyright, format, lint, cover, build ✨
.PHONY: all
all: tidy gen add-copyright verify test-api lint cover restart
# ==============================================================================
# Build set
ROOT_PACKAGE=github.com/openimsdk/open-im-server
# TODO: This is version control for the future https://github.com/openimsdk/open-im-server/issues/574
VERSION_PACKAGE=github.com/openimsdk/open-im-server/v3/pkg/version
# ==============================================================================
# Includes
include scripts/make-rules/common.mk # make sure include common.mk at the first include line
include scripts/make-rules/golang.mk
include scripts/make-rules/image.mk
include scripts/make-rules/copyright.mk
include scripts/make-rules/gen.mk
include scripts/make-rules/dependencies.mk
include scripts/make-rules/tools.mk
include scripts/make-rules/release.mk
include scripts/make-rules/swagger.mk
# ==============================================================================
# Usage
define USAGE_OPTIONS
Options:
DEBUG Whether or not to generate debug symbols. Default is 0.
BINS Binaries to build. Default is all binaries under cmd.
This option is available when using: make {build}(.multiarch)
Example: make build BINS="openim-api openim-cmdutils".
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
Example: make multiarch PLATFORMS="linux_s390x linux_mips64
linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64".
V Set to 1 enable verbose build. Default is 0.
endef
export USAGE_OPTIONS
# ==============================================================================
# Targets
## init: Initialize openim server project ✨
.PHONY: init
init:
@$(MAKE) gen.init
## init-githooks: Initialize git hooks ✨
.PHONY: init-githooks
init-githooks:
@$(MAKE) gen.init-githooks
## gen: Generate all necessary files. ✨
.PHONY: gen
gen:
@$(MAKE) gen.run
## demo: Run demo get started with Makefiles quickly ✨
.PHONY: demo
demo:
@$(MAKE) go.demo
## version: Check version of openim. ✨
.PHONY: version
version:
@$(MAKE) go.versionchecker
## build: Build binaries by default ✨
.PHONY: build
build:
@$(MAKE) go.build
## start: Start openim ✨
.PHONY: start
start:
@$(MAKE) go.start
## stop: Stop openim ✨
.PHONY: stop
stop:
@$(MAKE) go.stop
## restart: Restart openim (make init configuration file is initialized) ✨
.PHONY: restart
restart: clean stop build start check
## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨
.PHONY: multiarch
multiarch:
@$(MAKE) go.build.multiarch
## verify: execute all verity scripts. ✨
.PHONY: verify
verify:
@$(MAKE) go.verify
## install: Install deployment openim ✨
.PHONY: install
install:
@$(MAKE) go.install
## check: Check OpenIM deployment ✨
.PHONY: check
check:
@$(MAKE) go.check
## check-component: Check OpenIM component deployment ✨
.PHONY: check-component
check-component:
@$(MAKE) go.check-component
## tidy: tidy go.mod ✨
.PHONY: tidy
tidy:
@$(GO) mod tidy
## vendor: vendor go.mod ✨
.PHONY: vendor
vendor:
@$(GO) mod vendor
## style: code style -> fmt,vet,lint ✨
.PHONY: style
style: fmt vet lint
## fmt: Run go fmt against code. ✨
.PHONY: fmt
fmt:
@$(GO) fmt ./...
## vet: Run go vet against code. ✨
.PHONY: vet
vet:
@$(GO) vet ./...
## lint: Check syntax and styling of go sources. ✨
.PHONY: lint
lint:
@$(MAKE) go.lint
## format: Gofmt (reformat) package sources (exclude vendor dir if existed). ✨
.PHONY: format
format:
@$(MAKE) go.format
## test: Run unit test. ✨
.PHONY: test
test:
@$(MAKE) go.test
## cover: Run unit test and get test coverage. ✨
.PHONY: cover
cover:
@$(MAKE) go.test.cover
## test-api: Run api test. ✨
.PHONY: test-api
test-api:
@$(MAKE) go.test.api
## test-e2e: Run e2e test
test-e2e:
@$(MAKE) go.test.e2e
## updates: Check for updates to go.mod dependencies. ✨
.PHONY: updates
@$(MAKE) go.updates
## imports: task to automatically handle import packages in Go files using goimports tool. ✨
.PHONY: imports
imports:
@$(MAKE) go.imports
## clean: Delete all files created by the build, as well as all log files. ✨
.PHONY: clean
clean:
@$(MAKE) go.clean
## image: Build docker images for host arch. ✨
.PHONY: image
image:
@$(MAKE) image.build
## image.multiarch: Build docker images for multiple platforms. See option PLATFORMS. ✨
.PHONY: image.multiarch
image.multiarch:
@$(MAKE) image.build.multiarch
## push: Build docker images for host arch and push images to registry. ✨
.PHONY: push
push:
@$(MAKE) image.push
## push.multiarch: Build docker images for multiple platforms and push images to registry. ✨
.PHONY: push.multiarch
push.multiarch:
@$(MAKE) image.push.multiarch
## tools: Install dependent tools. ✨
.PHONY: tools
tools:
@$(MAKE) tools.install
## swagger: Generate swagger document. ✨
.PHONY: swagger
swagger:
@$(MAKE) swagger.run
## serve-swagger: Serve swagger spec and docs. ✨
.PHONY: swagger.serve
serve-swagger:
@$(MAKE) swagger.serve
## verify-copyright: Verify the license headers for all files. ✨
.PHONY: verify-copyright
verify-copyright:
@$(MAKE) copyright.verify
## add-copyright: Add copyright ensure source code files have license headers. ✨
.PHONY: add-copyright
add-copyright:
@$(MAKE) copyright.add
## advertise: Project introduction, become a contributor ✨
.PHONY: advertise
advertise:
@$(MAKE) copyright.advertise
## release: release the project ✨
.PHONY: release
release: release.verify release.ensure-tag
@scripts/release.sh
## help: Show this help info. ✨
.PHONY: help
help: Makefile
$(call makehelp)
## help-all: Show all help details info. ✨
.PHONY: help-all
help-all: go.help copyright.help tools.help image.help dependencies.help gen.help release.help swagger.help help
$(call makeallhelp)

@ -52,7 +52,7 @@
</p>
## 🟢 扫描微信进群交流
<img src="./docs/images/Wechat.jpg" width="300">
<img src="./docs/images/wechat.jpg" width="300">
## Ⓜ️ 关于 OpenIM

@ -0,0 +1,31 @@
@echo off
SETLOCAL
mage -version >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
echo Mage is already installed.
GOTO DOWNLOAD
)
go version >nul 2>&1
IF NOT %ERRORLEVEL% EQU 0 (
echo Go is not installed. Please install Go and try again.
exit /b 1
)
echo Installing Mage...
go install github.com/magefile/mage@latest
mage -version >nul 2>&1
IF NOT %ERRORLEVEL% EQU 0 (
echo Mage installation failed.
echo Please ensure that %GOPATH%/bin is in your PATH.
exit /b 1
)
echo Mage installed successfully.
:DOWNLOAD
go mod download
ENDLOCAL

@ -0,0 +1,23 @@
#!/bin/bash
if [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
TARGET_DIR="$HOME/.local/bin"
else
TARGET_DIR="/usr/local/bin"
echo "Using /usr/local/bin as the installation directory. Might require sudo permissions."
fi
if ! command -v mage &> /dev/null; then
echo "Installing Mage to $TARGET_DIR ..."
GOBIN=$TARGET_DIR go install github.com/magefile/mage@latest
fi
if ! command -v mage &> /dev/null; then
echo "Mage installation failed."
echo "Please ensure that $TARGET_DIR is in your \$PATH."
exit 1
fi
echo "Mage installed successfully."
go mod download

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -19,7 +19,6 @@
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server

@ -1,57 +0,0 @@
# 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.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy
FROM golang:1.20 AS builder
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.io,direct
WORKDIR /openim/openim-server
ENV GO111MODULE=$GO111MODULE
ENV GOPROXY=$GOPROXY
RUN apt-get update && apt-get install -y curl unzip
RUN curl -LO https://app-1302656840.cos.ap-nanjing.myqcloud.com/dist.zip \
&& unzip dist.zip -d ./ \
&& rm dist.zip
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make clean
RUN make build BINS=openim-web
FROM ghcr.io/openim-sigs/openim-ubuntu-image:latest
WORKDIR /openim/openim-server
COPY --from=builder /openim/openim-server/_output/bin/tools /openim/openim-server/_output/bin/tools/
COPY --from=builder /openim/openim-server/dist /openim/openim-server/dist
ENV PORT 11001
ENV DISTPATH /openim/openim-server/dist
EXPOSE 11001
RUN mv ${OPENIM_SERVER_BINDIR}/tools/$(get_os)/$(get_arch)/openim-web /usr/bin/openim-web
ENTRYPOINT ["bash", "-c", "openim-web -port $PORT -distPath $DISTPATH"]

@ -18,14 +18,12 @@ import (
_ "net/http/pprof"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
apiCmd := cmd.NewApiCmd()
apiCmd.AddPortFlag()
apiCmd.AddPrometheusPortFlag()
if err := apiCmd.Execute(); err != nil {
util.ExitWithError(err)
if err := cmd.NewApiCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -16,7 +16,7 @@ package main
import (
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
@ -29,6 +29,8 @@ func main() {
getCmd.AddCommand(seqCmd.GetSeqCmd(), msgCmd.GetMsgCmd())
getCmd.AddSuperGroupIDFlag()
getCmd.AddUserIDFlag()
getCmd.AddConfigDirFlag()
getCmd.AddIndexFlag()
getCmd.AddBeginSeqFlag()
getCmd.AddLimitFlag()
// openIM get seq --userID=xxx
@ -39,6 +41,8 @@ func main() {
fixCmd.AddCommand(seqCmd.FixSeqCmd())
fixCmd.AddSuperGroupIDFlag()
fixCmd.AddUserIDFlag()
fixCmd.AddConfigDirFlag()
fixCmd.AddIndexFlag()
fixCmd.AddFixAllFlag()
// openIM fix seq --userID=xxx
// openIM fix seq --superGroupID=xxx
@ -47,6 +51,8 @@ func main() {
clearCmd.AddCommand(msgCmd.ClearMsgCmd())
clearCmd.AddSuperGroupIDFlag()
clearCmd.AddUserIDFlag()
clearCmd.AddConfigDirFlag()
clearCmd.AddIndexFlag()
clearCmd.AddClearAllFlag()
clearCmd.AddBeginSeqFlag()
clearCmd.AddLimitFlag()
@ -55,6 +61,6 @@ func main() {
// openIM clear msg --clearAll
msgUtilsCmd.AddCommand(&getCmd.Command, &fixCmd.Command, &clearCmd.Command)
if err := msgUtilsCmd.Execute(); err != nil {
util.ExitWithError(err)
program.ExitWithError(err)
}
}

@ -16,12 +16,11 @@ package main
import (
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
cronTaskCmd := cmd.NewCronTaskCmd()
if err := cronTaskCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewCronTaskCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -16,15 +16,11 @@ package main
import (
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
msgGatewayCmd := cmd.NewMsgGatewayCmd()
msgGatewayCmd.AddWsPortFlag()
msgGatewayCmd.AddPortFlag()
msgGatewayCmd.AddPrometheusPortFlag()
if err := msgGatewayCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewMsgGatewayCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -16,14 +16,11 @@ package main
import (
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
msgTransferCmd := cmd.NewMsgTransferCmd()
msgTransferCmd.AddPrometheusPortFlag()
msgTransferCmd.AddTransferProgressFlag()
if err := msgTransferCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewMsgTransferCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -15,16 +15,12 @@
package main
import (
"github.com/openimsdk/open-im-server/v3/internal/push"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
pushCmd := cmd.NewRpcCmd(cmd.RpcPushServer, push.Start)
pushCmd.AddPortFlag()
pushCmd.AddPrometheusPortFlag()
if err := pushCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewPushRpcCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -15,16 +15,12 @@
package main
import (
"github.com/openimsdk/open-im-server/v3/internal/rpc/auth"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
authCmd := cmd.NewRpcCmd(cmd.RpcAuthServer, auth.Start)
authCmd.AddPortFlag()
authCmd.AddPrometheusPortFlag()
if err := authCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewAuthRpcCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -15,16 +15,12 @@
package main
import (
"github.com/openimsdk/open-im-server/v3/internal/rpc/conversation"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
rpcCmd := cmd.NewRpcCmd(cmd.RpcConversationServer, conversation.Start)
rpcCmd.AddPortFlag()
rpcCmd.AddPrometheusPortFlag()
if err := rpcCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewConversationRpcCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -15,16 +15,12 @@
package main
import (
"github.com/openimsdk/open-im-server/v3/internal/rpc/friend"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
rpcCmd := cmd.NewRpcCmd(cmd.RpcFriendServer, friend.Start)
rpcCmd.AddPortFlag()
rpcCmd.AddPrometheusPortFlag()
if err := rpcCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewFriendRpcCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -15,16 +15,12 @@
package main
import (
"github.com/openimsdk/open-im-server/v3/internal/rpc/group"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
rpcCmd := cmd.NewRpcCmd(cmd.RpcGroupServer, group.Start)
rpcCmd.AddPortFlag()
rpcCmd.AddPrometheusPortFlag()
if err := rpcCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewGroupRpcCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -15,16 +15,12 @@
package main
import (
"github.com/openimsdk/open-im-server/v3/internal/rpc/msg"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
rpcCmd := cmd.NewRpcCmd(cmd.RpcMsgServer, msg.Start)
rpcCmd.AddPortFlag()
rpcCmd.AddPrometheusPortFlag()
if err := rpcCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewMsgRpcCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -15,16 +15,12 @@
package main
import (
"github.com/openimsdk/open-im-server/v3/internal/rpc/third"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
rpcCmd := cmd.NewRpcCmd(cmd.RpcThirdServer, third.Start)
rpcCmd.AddPortFlag()
rpcCmd.AddPrometheusPortFlag()
if err := rpcCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewThirdRpcCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -15,16 +15,12 @@
package main
import (
"github.com/openimsdk/open-im-server/v3/internal/rpc/user"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/openimsdk/tools/system/program"
)
func main() {
rpcCmd := cmd.NewRpcCmd(cmd.RpcUserServer, user.Start)
rpcCmd.AddPortFlag()
rpcCmd.AddPrometheusPortFlag()
if err := rpcCmd.Exec(); err != nil {
util.ExitWithError(err)
if err := cmd.NewUserRpcCmd().Exec(); err != nil {
program.ExitWithError(err)
}
}

@ -0,0 +1,63 @@
---
title: 'OpenIM Configuration Files and Common Configuration Item Modifications Guide'
## Configuration Files Explanation
| Configuration File | Description |
| ------------------------------- | ------------------------------------------------------------ |
| **kafka.yml** | Configurations for Kafka username, password, address, etc. |
| **redis.yml** | Configurations for Redis password, address, etc. |
| **minio.yml** | Configurations for MinIO username, password, address, and external IP/domain; failing to modify external IP or domain may cause image file sending failures |
| **zookeeper.yml** | Configurations for ZooKeeper user, password, address, etc. |
| **mongodb.yml** | Configurations for MongoDB username, password, address, etc. |
| **log.yml** | Configurations for log level and storage directory. |
| **notification.yml** | Configurations for events like adding friends, creating groups, etc. |
| **share.yml** | Common configurations needed by various OpenIM services, such as secret. |
| **webhooks.yml** | Configurations for URLs in Webhook. |
| **local-cache.yml** | Local cache configurations. |
| **openim-rpc-third.yml** | Configurations for listening IP, port, and storage settings for images and videos in openim-rpc-third service. |
| **openim-rpc-user.yml** | Configurations for listening IP and port in openim-rpc-user service. |
| **openim-api.yml** | Configurations for listening IP, port, etc., in openim-api service. |
| **openim-crontask.yml** | Configurations for openim-crontask service. |
| **openim-msggateway.yml** | Configurations for listening IP, port, etc., in openim-msggateway service. |
| **openim-msgtransfer.yml** | Configurations for openim-msgtransfer service. |
| **openim-push.yml** | Configurations for listening IP, port, and offline push settings in openim-push service. |
| **openim-rpc-auth.yml** | Configurations for listening IP, port, and token expiration settings in openim-rpc-auth service. |
| **openim-rpc-conversation.yml** | Configurations for listening IP, port, etc., in openim-rpc-conversation service. |
| **openim-rpc-friend.yml** | Configurations for listening IP, port, etc., in openim-rpc-friend service. |
| **openim-rpc-group.yml** | Configurations for listening IP, port, etc., in openim-rpc-group service. |
| **openim-rpc-msg.yml** | Configurations for listening IP, port, and whether to verify friendship before sending messages in openim-rpc-msg service. |
## Common Configuration Item Modifications
| Configuration Item Modification | Configuration File |
| ----------------------------------------------------- | ----------------------- |
| Using MinIO for image and video file object storage | `minio.yml` |
| Adjusting production environment logs | `log.yml` |
| Verifying friendship before sending messages | `openim-rpc-msg.yml` |
| Modifying secret | `share.yml` |
| Using OSS, COS, AWS, Kodo for image and video storage | `openim-rpc-third.yml` |
| Setting multiple login policy | `openim-msggateway.yml` |
| Setting up offline push | `openim-push.yml` |
## Starting Multiple Instances of an OpenIM Service
To start multiple instances of an OpenIM service, simply increase the corresponding port numbers and modify the `start-config.yml` file in the project root directory. Restart the service to take effect. For example, the configuration to start 2 instances of `openim-rpc-user` is as follows:
```yaml
rpc:
registerIP: ''
listenIP: 0.0.0.0
ports: [ 10110, 10111 ]
prometheus:
enable: true
ports: [ 20100, 20101 ]
```
Modify `start-config.yml`:
```yaml
serviceBinaries:
openim-rpc-user: 2
```

@ -0,0 +1,65 @@
# OpenIM配置文件说明以及常用配置修改说明
## 配置文件说明
| Configuration File | Description |
| ------------------------------- | ------------------------------------------------------------ |
| **kafka.yml** | Kafka用户名、密码、地址等配置 |
| **redis.yml** | Redis密码、地址等配置 |
| **minio.yml** | MinIO用户名、密码、地址及外网IP域名等配置未修改外网IP或域名可能导致图片文件发送失败 |
| **zookeeper.yml** | ZooKeeper用户、密码、地址等配置 |
| **mongodb.yml** | MongoDB用户名、密码、地址等配置 |
| **log.yml** | 日志级别及存储目录等配置 |
| **notification.yml** | 添加好友、创建群组等事件通知配置 |
| **share.yml** | OpenIM各服务所需的公共配置如secret等 |
| **webhooks.yml** | Webhook中URL等配置 |
| **local-cache.yml** | 本地缓存配置 |
| **openim-rpc-third.yml** | openim-rpc-third服务的监听IP、端口及图片视频对象存储配置 |
| **openim-rpc-user.yml** | openim-rpc-user服务的监听IP、端口配置 |
| **openim-api.yml** | openim-api服务的监听IP、端口等配置项 |
| **openim-crontask.yml** | openim-crontask服务配置 |
| **openim-msggateway.yml** | openim-msggateway服务的监听IP、端口等配置 |
| **openim-msgtransfer.yml** | openim-msgtransfer服务配置 |
| **openim-push.yml** | openim-push服务的监听IP、端口及离线推送配置 |
| **openim-rpc-auth.yml** | openim-rpc-auth服务的监听IP、端口及token有效期等配置 |
| **openim-rpc-conversation.yml** | openim-rpc-conversation服务的监听IP、端口等配置 |
| **openim-rpc-friend.yml** | openim-rpc-friend服务的监听IP、端口等配置 |
| **openim-rpc-group.yml** | openim-rpc-group服务的监听IP、端口等配置 |
| **openim-rpc-msg.yml** | openim-rpc-msg服务的监听IP、端口及消息发送是否验证好友关系等配置 |
## 常用配置修改
| 修改配置项 | 配置文件 |
| ----------------------------------------------- | ----------------------- |
| 使用minio作为图片视频文件对象存储 | `minio.yml` |
| 生产环境日志调整 | `log.yml` |
| 发送消息是否验证好友关系 | `openim-rpc-msg.yml` |
| 修改secret | `share.yml` |
| 使用oss, cos, aws, kodo作为图片视频文件对象存储 | `openim-rpc-third.yml` |
| 设置多端互踢策略 | `openim-msggateway.yml` |
| 设置离线推送 | `openim-push.yml` |
## 启动某个OpenIM服务的多个实例
若要启动某个OpenIM的多个实例只需增加对应的端口数并修改项目根目录下的`start-config.yml`文件重启服务即可生效。例如启动2个`openim-rpc-user`实例的配置如下:
```yaml
rpc:
registerIP: ''
listenIP: 0.0.0.0
ports: [ 10110, 10111 ]
prometheus:
enable: true
ports: [ 20100, 20101 ]
```
修改`start-config.yml`:
```yaml
serviceBinaries:
openim-rpc-user: 2
```

@ -1,243 +0,0 @@
# OpenIM Configuration Guide
<!-- vscode-markdown-toc -->
* 1. [Directory Structure and File Descriptions](#DirectoryStructureandFileDescriptions)
* 1.1. [Directory Structure](#DirectoryStructure)
* 1.2. [Directory Structure Explanation](#DirectoryStructureExplanation)
* 2. [File Descriptions](#FileDescriptions)
* 2.1. [Files in the Root Directory](#FilesintheRootDirectory)
* 2.2. [Files in the `templates/` Directory](#FilesinthetemplatesDirectory)
* 3. [Configuration File Generation](#ConfigurationFileGeneration)
* 3.1. [How to Use `init-config.sh` Script](#HowtoUseinit-config.shScript)
* 3.2. [Examples of Operations](#ExamplesofOperations)
* 3.3. [Points to Note](#PointstoNote)
* 4. [Example Directory](#ExampleDirectory)
* 4.1. [Overview](#Overview)
* 4.2. [Structure](#Structure)
* 4.3. [How to Use These Examples](#HowtoUseTheseExamples)
* 4.4. [Tips for Using Example Files:](#TipsforUsingExampleFiles:)
* 5. [Configuration Item Descriptions](#ConfigurationItemDescriptions)
* 6. [Version Management and Upgrading](#VersionManagementandUpgrading)
* 6.1. [Pulling the Latest Code](#PullingtheLatestCode)
* 6.2. [Generating the Latest Example Configuration Files](#GeneratingtheLatestExampleConfigurationFiles)
* 6.3. [Comparing Configuration File Differences](#ComparingConfigurationFileDifferences)
* 6.4. [Updating Configuration Files](#UpdatingConfigurationFiles)
* 6.5. [Updating Binary Files and Restarting Services](#UpdatingBinaryFilesandRestartingServices)
* 6.6. [Best Practices for Version Management](#BestPracticesforVersionManagement)
* 7. [How to Contribute](#HowtoContribute)
* 7.1. [OpenIM Configuration Item Descriptions](#OpenIMConfigurationItemDescriptions)
* 7.2. [Modifying Template Files](#ModifyingTemplateFiles)
* 7.3. [Updating Configuration Center Scripts](#UpdatingConfigurationCenterScripts)
* 7.4. [Configuration File Generation Process](#ConfigurationFileGenerationProcess)
* 7.5. [Contribution Guidelines](#ContributionGuidelines)
* 7.6. [Submission and Review](#SubmissionandReview)
<!-- vscode-markdown-toc-config
numbering=true
autoSave=true
/vscode-markdown-toc-config -->
<!-- /vscode-markdown-toc -->
## 1. <a name='DirectoryStructureandFileDescriptions'></a>Directory Structure and File Descriptions
This document details the structure of the `config` directory, aiding users in understanding and managing configuration files.
### 1.1. <a name='DirectoryStructure'></a>Directory Structure
```bash
$ tree config
├── alertmanager.yml
├── config.yaml
├── email.tmpl
├── instance-down-rules.yml
├── notification.yaml
├── prometheus.yml
├── Readme.md
└── templates
├── alertmanager.yml.template
├── config.yaml.template
├── email.tmpl.template
├── env.template
├── instance-down-rules.yml.template
├── notification.yaml.template
├── open-im-ng-example.conf
├── prometheus-dashboard.yaml
└── prometheus.yml.template
```
### 1.2. <a name='DirectoryStructureExplanation'></a>Directory Structure Explanation
- **Root Directory (`config/`)**: Contains actual configuration files and the `templates` subdirectory.
- **`templates/` Subdirectory**: Stores configuration templates for generating or updating configuration files in the root directory.
## 2. <a name='FileDescriptions'></a>File Descriptions
### 2.1. <a name='FilesintheRootDirectory'></a>Files in the Root Directory
- **`alertmanager.yml`**: Configuration file for AlertManager, managing and setting up the alert system.
- **`config.yaml`**: The main application configuration file, covering service settings.
- **`email.tmpl`**: Template file for email notifications, defining email format and content.
- **`instance-down-rules.yml`**: Instance downtime rules configuration file for the monitoring system.
- **`notification.yaml`**: Configuration file for notification settings, defining different types of notifications.
- **`prometheus.yml`**: Configuration file for the Prometheus monitoring system, setting monitoring metrics and rules.
### 2.2. <a name='FilesinthetemplatesDirectory'></a>Files in the `templates/` Directory
- **`alertmanager.yml.template`**: Template for AlertManager configuration.
- **`config.yaml.template`**: Main configuration template for the application.
- **`email.tmpl.template`**: Template for email notifications.
- **`env.template`**: Template for environmental variable configurations, setting environment-related configurations.
- **`instance-down-rules.yml.template`**: Template for instance downtime rules.
- **`notification.yaml.template`**: Template for notification settings.
- **`open-im-ng-example.conf`**: Example configuration file for the application.
- **`prometheus-dashboard.yaml`**: Prometheus dashboard configuration file, specific to the OpenIM application.
- **`prometheus.yml.template`**: Template for Prometheus configuration.
## 3. <a name='ConfigurationFileGeneration'></a>Configuration File Generation
Configuration files can be automatically generated using the `make init` command or the `./scripts/init-config.sh` script. These scripts conveniently extract templates from the `templates` directory and generate or update actual configuration files in the root directory.
### 3.1. <a name='HowtoUseinit-config.shScript'></a>How to Use `init-config.sh` Script
```bash
$ ./scripts/init-config.sh --help
Usage: init-config.sh [options]
Options:
-h, --help Show this help message
--force Overwrite existing files without prompt
--skip Skip generation if file exists
--examples Generate example files
--clean-config Clean all configuration files
--clean-examples Clean all example files
```
### 3.2. <a name='ExamplesofOperations'></a>Examples of Operations
- Generate all template configuration files:
```bash
$ ./scripts/init-config.sh --examples
```
- Force overwrite existing configuration files:
```bash
$ ./scripts/init-config.sh --force
```
### 3.3. <a name='PointstoNote'></a>Points to Note
- **Template files should not be directly modified**: Files in the `template` directory are templates included in source code management. Direct modification may lead to version conflicts or management issues.
- **Operations for Windows Users**: Windows users can use the `cp` command to copy files from the `template` directory to the `config/` directory and then modify the configuration items as needed.
## 4. <a name='ExampleDirectory'></a>Example Directory
Welcome to our project's `examples` directory! This directory contains a range of example files, showcasing various configurations and settings of our software. These examples are intended to provide you with templates that can serve as a starting point for your own configurations.
### 4.1. <a name='Overview'></a>Overview
In this directory, you'll find examples suitable for a variety of use cases. Each file is a template with default values and configurations, demonstrating best practices and typical scenarios. Whether you're just getting started or looking to implement complex settings, these examples should help you get on the right track.
### 4.2. <a name='Structure'></a>Structure
Here's a quick overview of the contents in this directory:
- `env-example.yaml`: Demonstrates how to set up environmental variables.
- `openim-example.yaml`: Example configuration file for the OpenIM application.
- `prometheus-example.yml`: Example configuration for monitoring with Prometheus.
- `alertmanager-example.yml`: Template for setting up Alertmanager configuration.
### 4.3. <a name='HowtoUseTheseExamples'></a>How to Use These Examples
To use these examples, simply copy the relevant files to your working directory and rename them as needed (for example, removing the `-example` suffix). Then, modify the files according to your needs.
### 4.4. <a name='TipsforUsingExampleFiles:'></a>Tips for Using Example Files:
1. **Read Comments**: Each file contains comments explaining the various sections and settings. Make sure to read these comments for a better understanding of how to customize the file.
2. **Check Required Changes**: Some examples might require mandatory changes before they can be used effectively (such as setting specific environmental variables).
3. **Version Compatibility**: Ensure that the example files are compatible with the version of the software you are using.
## 5. <a name='ConfigurationItemDescriptions'></a>Configuration Item Descriptions
## 6. <a name='VersionManagementandUpgrading'></a>Version Management and Upgrading
When managing and upgrading the `config` directory's versions, it is crucial to ensure that the configuration files in both the local `config/` and `config/templates/` directories are kept in sync. This process can ensure that your configuration files are consistent with the latest standard templates, while also maintaining custom settings.
### 6.1. <a name='PullingtheLatestCode'></a>Pulling the Latest Code
First, ensure that your local repository is in sync with the remote repository. This can be achieved by pulling the latest code:
```bash
$ git pull
```
### 6.2. <a name='GeneratingtheLatestExampleConfigurationFiles'></a>Generating the Latest Example Configuration Files
Next, generate the latest example configuration files. This can be done by running the `init-config.sh` script, using the `--examples` option to generate example files, and the `--skip` option to avoid overwriting existing configuration files:
```bash
$ ./scripts/init-config.sh --examples --skip
```
### 6.3. <a name='ComparingConfigurationFileDifferences'></a>Comparing Configuration File Differences
Once the latest example configuration files are generated, you need to compare the configuration files in the `config/` and `config/templates/` directories to find any potential differences. This step ensures that you can identify and integrate any important updates or changes. Tools like `diff` can be helpful in completing this step:
```bash
$ diff -ur config/ config/templates/
```
### 6.4. <a name='UpdatingConfigurationFiles'></a>Updating Configuration Files
Based on the comparison results, manually update the configuration files in the `config/` directory to reflect the latest configurations in `config/templates/`. During this process, ensure to retain any custom configuration settings.
### 6.5. <a name='UpdatingBinaryFilesandRestartingServices'></a>Updating Binary Files and Restarting Services
After updating the configuration files, the next step is to update any related binary files. This typically involves downloading and installing the latest version of the application or service. Depending on the specific application or service, this might involve running specific update scripts or directly downloading the latest version from official sources.
Once the binary files are updated, the services need to be restarted to apply the new configurations. Make sure to conduct necessary checks before restarting to ensure the correctness of the configurations.
### 6.6. <a name='BestPracticesforVersionManagement'></a>Best Practices for Version Management
- **Record Changes**: When committing changes to a version control system, ensure to log detailed change logs.
- **Stay Synced**: Regularly sync with the remote repository to ensure that your local configurations are in line with the latest developments.
- **Backup**: Backup your current configurations before making any significant changes, so that you can revert to a previous state if necessary.
By following these steps and best practices, you can ensure effective management and smooth upgrading of your `config` directory.
## 7. <a name='HowtoContribute'></a>How to Contribute
If you have an understanding of the logic behind OpenIM's configuration generation, then you will clearly know where to make modifications to contribute code.
### 7.1. <a name='OpenIMConfigurationItemDescriptions'></a>OpenIM Configuration Item Descriptions
First, it is recommended to read the [OpenIM Configuration Items Document](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md). This will help you understand the roles of various configuration items and how they affect the operation of OpenIM.
### 7.2. <a name='ModifyingTemplateFiles'></a>Modifying Template Files
To contribute to OpenIM, focus on the `./deployments/templates` directory. This contains various configuration template files, which are the basis for generating the final configuration files.
When making modifications, ensure that your changes align with OpenIM's configuration requirements and logic. This may involve adding new template files or modifying existing files to reflect new configuration options or structural changes.
### 7.3. <a name='UpdatingConfigurationCenterScripts'></a>Updating Configuration Center Scripts
In addition to modifying template files, pay attention to the `./scripts/install/environment.sh` script. In this script, you may need to add or modify environment variables.
This script is responsible for defining environment variables that influence configuration generation. Therefore, any new configuration items or modifications to existing items need to be reflected here.
### 7.4. <a name='ConfigurationFileGenerationProcess'></a>Configuration File Generation Process
The essence of the `make init` command is to use the environment variables defined in `/scripts/install/environment.sh` to render the template files in the `./deployments/templates` directory, thereby generating the final configuration files.
When contributing code, ensure that your changes work smoothly in this process and do not cause errors during configuration file generation.
### 7.5. <a name='ContributionGuidelines'></a>Contribution Guidelines
- **Code Review**: Ensure your changes have passed code review. This typically means that the code should be clear, easy to understand, and adhere to the project's coding style and best practices.
- **Testing**: Before submitting changes, conduct thorough tests to ensure new or modified configurations work as expected and do not negatively impact existing functionalities.
- **Documentation**: If you have added a new configuration option or made significant changes to an existing one, update the relevant documentation to assist other users and developers in understanding and utilizing these changes.
### 7.6. <a name='SubmissionandReview'></a>Submission and Review
After completing your changes, submit your code to the OpenIM repository in the form of a Pull Request (PR). The PR will be reviewed by the project maintainers and you may be asked to make further modifications or provide additional information.

@ -0,0 +1,18 @@
username: ''
password: ''
producerAck: ""
compressType: "none"
address: [ localhost:19094 ]
toRedisTopic: "toRedis"
toMongoTopic: "toMongo"
toPushTopic: "toPush"
toRedisGroupID: redis
toMongoGroupID: mongo
toPushGroupID: push
tls:
enableTLS: false
caCrt: ""
clientCrt: ""
clientKey: ""
clientKeyPwd: ""
insecureSkipVerify: false

@ -0,0 +1,27 @@
user:
topic: DELETE_CACHE_USER
slotNum: 100
slotSize: 2000
successExpire: 300
failedExpire: 5
group:
topic: DELETE_CACHE_GROUP
slotNum: 100
slotSize: 2000
successExpire: 300
failedExpire: 5
friend:
topic: DELETE_CACHE_FRIEND
slotNum: 100
slotSize: 2000
successExpire: 300
failedExpire: 5
conversation:
topic: DELETE_CACHE_CONVERSATION
slotNum: 100
slotSize: 2000
successExpire: 300
failedExpire: 5

@ -0,0 +1,13 @@
# Log storage path, default is acceptable, change to a full path if modification is needed
storageLocation: ../../../../logs/
# Log rotation period (in hours), default is acceptable
rotationTime: 24
# Number of log files to retain, default is acceptable
remainRotationCount: 2
# Log level settings: 3 for production environment; 6 for more verbose logging in debugging environments
remainLogLevel: 6
# Whether to output to standard output, default is acceptable
isStdout: false
# Whether to log in JSON format, default is acceptable
isJson: false

@ -0,0 +1,7 @@
bucket: "openim"
accessKeyID: "root"
secretAccessKey: "openIM123"
sessionToken: ''
internalAddress: "minio:9000"
externalAddress: "http://external_ip:10005"
publicRead: false

@ -0,0 +1,7 @@
uri: ''
address: [ localhost:37017 ]
database: openim_v3
username: openIM
password: openIM123
maxPoolSize: 100
maxRetry: 10

@ -0,0 +1,354 @@
# 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.
# Determines if a message should be sent. If set to false, it triggers a silent sync without a message. If true, it requires triggering a conversation.
# For rpc notification, send twice: once as a message and once as a notification.
# The options field 'isNotification' indicates if it's a notification.
groupCreated:
isSendMsg: true
# Reliability level of the message sending.
# Set to 1 to send only when online, 2 for guaranteed delivery.
reliabilityLevel: 1
# This setting is effective only when 'isSendMsg' is true.
# It controls whether to count unread messages.
unreadCount: false
# Configuration for offline push notifications.
offlinePush:
# Enables or disables offline push notifications.
enable: false
# Title for the notification when a group is created.
title: "create group title"
# Description for the notification.
desc: "create group desc"
# Additional information for the notification.
ext: "create group ext"
# Content type is not added here.
# Content should use a JSON structure conforming to the protobuf format.
groupInfoSet:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupInfoSet title"
desc: "groupInfoSet desc"
ext: "groupInfoSet ext"
joinGroupApplication:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "joinGroupApplication title"
desc: "joinGroupApplication desc"
ext: "joinGroupApplication ext"
memberQuit:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "memberQuit title"
desc: "memberQuit desc"
ext: "memberQuit ext"
groupApplicationAccepted:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupApplicationAccepted title"
desc: "groupApplicationAccepted desc"
ext: "groupApplicationAccepted ext"
groupApplicationRejected:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupApplicationRejected title"
desc: "groupApplicationRejected desc"
ext: "groupApplicationRejected ext"
groupOwnerTransferred:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupOwnerTransferred title"
desc: "groupOwnerTransferred desc"
ext: "groupOwnerTransferred ext"
memberKicked:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "memberKicked title"
desc: "memberKicked desc"
ext: "memberKicked ext"
memberInvited:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "memberInvited title"
desc: "memberInvited desc"
ext: "memberInvited ext"
memberEnter:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "memberEnter title"
desc: "memberEnter desc"
ext: "memberEnter ext"
groupDismissed:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupDismissed title"
desc: "groupDismissed desc"
ext: "groupDismissed ext"
groupMuted:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupMuted title"
desc: "groupMuted desc"
ext: "groupMuted ext"
groupCancelMuted:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupCancelMuted title"
desc: "groupCancelMuted desc"
ext: "groupCancelMuted ext"
defaultTips:
tips: "group Cancel Muted"
groupMemberMuted:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupMemberMuted title"
desc: "groupMemberMuted desc"
ext: "groupMemberMuted ext"
groupMemberCancelMuted:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupMemberCancelMuted title"
desc: "groupMemberCancelMuted desc"
ext: "groupMemberCancelMuted ext"
groupMemberInfoSet:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupMemberInfoSet title"
desc: "groupMemberInfoSet desc"
ext: "groupMemberInfoSet ext"
groupInfoSetAnnouncement:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupInfoSetAnnouncement title"
desc: "groupInfoSetAnnouncement desc"
ext: "groupInfoSetAnnouncement ext"
groupInfoSetName:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "groupInfoSetName title"
desc: "groupInfoSetName desc"
ext: "groupInfoSetName ext"
#############################friend#################################
friendApplicationAdded:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "Somebody applies to add you as a friend"
desc: "Somebody applies to add you as a friend"
ext: "Somebody applies to add you as a friend"
friendApplicationApproved:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "Someone applies to add your friend application"
desc: "Someone applies to add your friend application"
ext: "Someone applies to add your friend application"
friendApplicationRejected:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "Someone rejected your friend application"
desc: "Someone rejected your friend application"
ext: "Someone rejected your friend application"
friendAdded:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "We have become friends"
desc: "We have become friends"
ext: "We have become friends"
friendDeleted:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "deleted a friend"
desc: "deleted a friend"
ext: "deleted a friend"
friendRemarkSet:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "Your friend's profile has been changed"
desc: "Your friend's profile has been changed"
ext: "Your friend's profile has been changed"
blackAdded:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "blocked a user"
desc: "blocked a user"
ext: "blocked a user"
blackDeleted:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "Remove a blocked user"
desc: "Remove a blocked user"
ext: "Remove a blocked user"
friendInfoUpdated:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "friend info updated"
desc: "friend info updated"
ext: "friend info updated"
#####################user#########################
userInfoUpdated:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "Remove a blocked user"
desc: "Remove a blocked user"
ext: "Remove a blocked user"
userStatusChanged:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: false
title: "user status changed"
desc: "user status changed"
ext: "user status changed"
#####################conversation#########################
conversationChanged:
isSendMsg: false
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "conversation changed"
desc: "conversation changed"
ext: "conversation changed"
conversationSetPrivate:
isSendMsg: true
reliabilityLevel: 1
unreadCount: false
offlinePush:
enable: true
title: "burn after reading"
desc: "burn after reading"
ext: "burn after reading"

@ -0,0 +1,13 @@
api:
# Listening IP; 0.0.0.0 means both internal and external IPs are listened to, default is recommended
listenIP: 0.0.0.0
# Listening ports; if multiple are configured, multiple instances will be launched, must be consistent with the number of prometheus.ports
ports: [ 10002 ]
prometheus:
# Whether to enable prometheus
enable: true
# Prometheus listening ports, must match the number of api.ports
ports: [ 20113 ]
# This address can be accessed via a browser
grafanaURL: http://127.0.0.1:13000/

@ -0,0 +1,4 @@
chatRecordsClearTime: "0 2 * * 3"
msgDestructTime: "0 2 * * *"
retainChatRecords: 365
enableCronLocker: false

@ -0,0 +1,19 @@
rpc:
registerIP: ''
ports: [ 10140 ]
prometheus:
enable: true
ports: [ 20112 ]
listenIP: 0.0.0.0
longConnSvr:
ports: [ 10001 ]
websocketMaxConnNum: 100000
websocketMaxMsgLen: 4096
websocketTimeout: 10
multiLoginPolicy: 1

@ -0,0 +1,3 @@
prometheus:
enable: true
ports: [ 20108, 20109, 20110, 20111 ]

@ -0,0 +1,37 @@
rpc:
registerIP: ''
listenIP: 0.0.0.0
ports: [ 10170 ]
prometheus:
enable: true
ports: [ 20107 ]
maxConcurrentWorkers: 3
enable: getui
geTui:
pushUrl: "https://restapi.getui.com/v2/$appId"
masterSecret: ''
appKey: ''
intent: ''
channelID: ''
channelName: ''
fcm:
serviceAccount: "x.json"
jpns:
appKey: ''
masterSecret: ''
pushURL: ''
pushIntent: ''
iosPush:
pushSound: "xxx"
badgeCount: true
production: false

@ -0,0 +1,13 @@
rpc:
registerIP: ''
listenIP: 0.0.0.0
ports: [ 10160 ]
prometheus:
enable: true
ports: [ 20106 ]
tokenPolicy:
#token有效期单位
expire: 90

@ -0,0 +1,11 @@
rpc:
registerIP: ''
listenIP: 0.0.0.0
ports: [ 10180 ]
prometheus:
enable: true
ports: [ 20105 ]

@ -0,0 +1,8 @@
rpc:
registerIP: ''
listenIP: 0.0.0.0
ports: [ 10120 ]
prometheus:
enable: true
ports: [ 20104 ]

@ -0,0 +1,9 @@
rpc:
registerIP: ''
listenIP: 0.0.0.0
ports: [ 10150 ]
prometheus:
enable: true
ports: [ 20103 ]

@ -0,0 +1,14 @@
rpc:
registerIP: ''
listenIP: 0.0.0.0
ports: [ 10130 ]
prometheus:
enable: true
ports: [ 20102 ]
#发消息是否需要好友验证
friendVerify: false

@ -0,0 +1,40 @@
rpc:
registerIP: ''
listenIP: 0.0.0.0
ports: [ 10190 ]
prometheus:
enable: true
ports: [ 20101 ]
object:
enable: "minio"
cos:
bucketURL: https://temp-1252357374.cos.ap-chengdu.myqcloud.com
secretID: ''
secretKey: ''
sessionToken: ''
publicRead: false
oss:
endpoint: "https://oss-cn-chengdu.aliyuncs.com"
bucket: "demo-9999999"
bucketURL: "https://demo-9999999.oss-cn-chengdu.aliyuncs.com"
accessKeyID: ''
accessKeySecret: ''
sessionToken: ''
publicRead: false
kodo:
endpoint: "webhook://s3.cn-east-1.qiniucs.com"
bucket: "demo-9999999"
bucketURL: "webhook://your.domain.com"
accessKeyID: ''
accessKeySecret: ''
sessionToken: ''
publicRead: false
aws:
endpoint: "''"
region: "us-east-1"
bucket: "demo-9999999"
accessKeyID: ''
accessKeySecret: ''
publicRead: false

@ -0,0 +1,17 @@
rpc:
# API or other RPCs can access this RPC through this IP; if left blank, the internal network IP is obtained by default
registerIP: ''
# Listening IP; 0.0.0.0 means both internal and external IPs are listened to, if blank, the internal network IP is automatically obtained by default
listenIP: 0.0.0.0
# Listening ports; if multiple are configured, multiple instances will be launched, and must be consistent with the number of prometheus.ports
ports: [ 10110 ]
prometheus:
# Whether to enable prometheus
enable: true
# Prometheus listening ports, must be consistent with the number of rpc.ports
ports: [ 20100 ]

@ -0,0 +1,7 @@
address: [ localhost:16379 ]
username: ''
password: openIM123
enablePipeline: false
clusterMode: false
db: 0
maxRetry: 10

@ -0,0 +1,15 @@
secret: openIM123
env: zookeeper
rpcRegisterName:
user: user
friend: friend
msg: msg
push: push
messageGateway: messageGateway
group: group
auth: auth
conversation: conversation
third: third
imAdminUserID: [ "imAdmin" ]

@ -1,24 +1,3 @@
# 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.
# -----------------------------------------------------------------
# TODO: This config file is the template file
# --| source: deployments/templates/config.yaml
# --| env: scripts/install/environment
# --| target: config/config.yaml
# -----------------------------------------------------------------
envs:
discovery: zookeeper
@ -122,14 +101,14 @@ api:
# minio.signEndpoint is minio public network address
object:
enable: "minio"
apiURL: "http://172.28.0.1:10002"
apiURL: "http://127.0.0.1:10002"
minio:
bucket: "openim"
endpoint: "http://172.28.0.1:10005"
accessKeyID: "root"
secretAccessKey: "openIM123"
sessionToken: ''
signEndpoint: "http://172.28.0.1:10005"
signEndpoint: "http://127.0.0.1:10005"
publicRead: false
cos:
bucketURL: https://temp-1252357374.cos.ap-chengdu.myqcloud.com
@ -154,8 +133,8 @@ object:
sessionToken: ''
publicRead: false
aws:
endpoint: ""
region: ""
endpoint: "''" # This might not be necessary unless you're using a custom endpoint
region: "us-east-1"
bucket: "demo-9999999"
accessKeyID: ''
accessKeySecret: ''
@ -200,7 +179,7 @@ rpcRegisterName:
# Whether to output in json format
# Whether to include stack trace in logs
log:
storageLocation: /workspaces/open-im-server/logs/
storageLocation: /data/workspaces/open-im-server/_output/logs/
rotationTime: 24
remainRotationCount: 2
remainLogLevel: 6
@ -250,9 +229,10 @@ push:
#
# Built-in app manager user IDs
# Built-in app manager nicknames
# Attention, this configure is discarded. If you have used him before, configure your own
manager:
userID: [ "openIM123456", "openIM654321", "openIMAdmin" ]
nickname: [ "system1", "system2", "system3" ]
userID:
nickname:
# chatAdmin, use for send notification
#
@ -336,7 +316,7 @@ callback:
timeout: 5
failedContinue: true
afterSendSingleMsg:
enable: true
enable: false
timeout: 5
failedContinue: true
beforeSendGroupMsg:
@ -521,7 +501,7 @@ callback:
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
prometheus:
enable: true
grafanaUrl: http://172.28.0.1:13000/
grafanaUrl: http://127.0.0.1:13000/
apiPrometheusPort: [20100]
userPrometheusPort: [ 20110 ]
friendPrometheusPort: [ 20120 ]
@ -534,3 +514,39 @@ prometheus:
rtcPrometheusPort: [ 21300 ]
thirdPrometheusPort: [ 21301 ]
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports
###################### LocalCache configuration information ######################
# topic: redis subscriber channel
# slotNum: number of slots, multiple slots can prevent too many keys from competing for a lock
# slotSize: number of slots, the number of cached keys per slot, the overall cache quantity is slotNum * slotSize
# successExpire: successful cache time seconds
# failedExpire: failed cache time seconds
# disable local caching and annotate topic, slotNum, and slotSize
localCache:
user:
topic: DELETE_CACHE_USER
slotNum: 100
slotSize: 2000
successExpire: 300
failedExpire: 5
group:
topic: DELETE_CACHE_GROUP
slotNum: 100
slotSize: 2000
successExpire: 300
failedExpire: 5
friend:
topic: DELETE_CACHE_FRIEND
slotNum: 100
slotSize: 2000
successExpire: 300
failedExpire: 5
conversation:
topic: DELETE_CACHE_CONVERSATION
slotNum: 100
slotSize: 2000
successExpire: 300
failedExpire: 5

@ -25,7 +25,7 @@
# Data storage directory for persistent data.
# Example: DATA_DIR=/path/to/data
DATA_DIR=/workspaces/open-im-server
DATA_DIR=/data/workspaces/open-im-server
# Docker image registry. Uncomment the preferred one.
# Options: ghcr.io/openimsdk, openim, registry.cn-hangzhou.aliyuncs.com/openimsdk
@ -91,7 +91,7 @@ ALERT_MANAGER_NETWORK_ADDRESS=172.28.0.14
# ==============================================================================
# Local IP address of the service. Modify if necessary.
# Example: OPENIM_IP=172.28.0.1
OPENIM_IP=172.28.0.1
OPENIM_IP=127.0.0.1
# ----- ZooKeeper Configuration -----
# Port for ZooKeeper service.
@ -100,7 +100,7 @@ ZOOKEEPER_PORT=12181
# MongoDB service port configuration.
# Default: MONGO_PORT=37017
# MONGO_PORT=37017
MONGO_PORT=37017
# Password for MongoDB admin user. Used for service authentication.
# Default: MONGO_PASSWORD=openIM123
@ -143,7 +143,7 @@ KAFKA_LATESTMSG_REDIS_TOPIC=latestMsgToRedis
# MINIO_PORT
# ----------
# MINIO_PORT sets the port for the MinIO object storage service.
# Upon changing this port, the MinIO endpoint URLs in the file must be updated
# Upon changing this port, the MinIO endpoint URLs in the config/config.yaml file must be updated
# to reflect this change. The endpoints include both the 'endpoint' and 'signEndpoint'
# under the MinIO configuration.
#

@ -66,6 +66,7 @@ server {
proxy_set_header Connection "Upgrade";
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Request-Api $scheme://$host/api;
proxy_pass http://im_api/;
}
location ^~/grafana/ { #10007 prometheus

@ -1213,7 +1213,7 @@
"editorMode": "code",
"expr": "sum(rate(app_requests_total{job=~\"^($job)$\"}[$interval])) by (job)",
"instant": false,
"legendFormat": "{{job}}-http",
"legendFormat": "{{job}}-webhook",
"range": true,
"refId": "A"
},

@ -0,0 +1,156 @@
url: "webhook://127.0.0.1:10008/callbackExample"
beforeSendSingleMsg:
enable: false
timeout: 5
failedContinue: true
beforeUpdateUserInfoEx:
enable: false
timeout: 5
failedContinue: true
afterUpdateUserInfoEx:
enable: false
timeout: 5
afterSendSingleMsg:
enable: false
timeout: 5
beforeSendGroupMsg:
enable: false
timeout: 5
failedContinue: true
beforeMsgModify:
enable: false
timeout: 5
failedContinue: true
afterSendGroupMsg:
enable: false
timeout: 5
afterUserOnline:
enable: false
timeout: 5
afterUserOffline:
enable: false
timeout: 5
afterUserKickOff:
enable: false
timeout: 5
beforeOfflinePush:
enable: false
timeout: 5
failedContinue: true
beforeOnlinePush:
enable: false
timeout: 5
failedContinue: true
beforeGroupOnlinePush:
enable: false
timeout: 5
failedContinue: true
beforeAddFriend:
enable: false
timeout: 5
failedContinue: true
beforeUpdateUserInfo:
enable: false
timeout: 5
failedContinue: true
afterUpdateUserInfo:
enable: false
timeout: 5
beforeCreateGroup:
enable: false
timeout: 5
failedContinue: true
afterCreateGroup:
enable: false
timeout: 5
beforeMemberJoinGroup:
enable: false
timeout: 5
failedContinue: true
beforeSetGroupMemberInfo:
enable: false
timeout: 5
failedContinue: true
afterSetGroupMemberInfo:
enable: false
timeout: 5
afterQuitGroup:
enable: false
timeout: 5
afterKickGroupMember:
enable: false
timeout: 5
afterDismissGroup:
enable: false
timeout: 5
beforeApplyJoinGroup:
enable: false
timeout: 5
failedContinue: true
afterGroupMsgRead:
enable: false
timeout: 5
afterSingleMsgRead:
enable: false
timeout: 5
beforeUserRegister:
enable: false
timeout: 5
failedContinue: true
afterUserRegister:
enable: false
timeout: 5
afterTransferGroupOwner:
enable: false
timeout: 5
beforeSetFriendRemark:
enable: false
timeout: 5
failedContinue: true
afterSetFriendRemark:
enable: false
timeout: 5
afterGroupMsgRevoke:
enable: false
timeout: 5
afterJoinGroup:
enable: false
timeout: 5
beforeInviteUserToGroup:
enable: false
timeout: 5
failedContinue: true
afterSetGroupInfo:
enable: false
timeout: 5
beforeSetGroupInfo:
enable: false
timeout: 5
failedContinue: true
afterRevokeMsg:
enable: false
timeout: 5
beforeAddBlack:
enable: false
timeout: 5
failedContinue:
afterAddFriend:
enable: false
timeout: 5
beforeAddFriendAgree:
enable: false
timeout: 5
failedContinue: true
afterDeleteFriend:
enable: false
timeout: 5
beforeImportFriends:
enable: false
timeout: 5
failedContinue: true
afterImportFriends:
enable: false
timeout: 5
afterRemoveBlack:
enable: false
timeout: 5

@ -0,0 +1,6 @@
schema: openim
address: [ localhost:12181 ]
username: ''
password: ''

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-api.selectorLabels" . | nindent 4 }}

@ -48,7 +48,7 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
- name: rpc
@ -57,11 +57,11 @@ spec:
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,9 +22,9 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
- port: 88
targetPort: rpc
protocol: TCP

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-msgtransfer.selectorLabels" . | nindent 4 }}

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-push.selectorLabels" . | nindent 4 }}

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-rpc-auth.selectorLabels" . | nindent 4 }}

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-rpc-conversation.selectorLabels" . | nindent 4 }}

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-rpc-friend.selectorLabels" . | nindent 4 }}

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-rpc-group.selectorLabels" . | nindent 4 }}

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-rpc-msg.selectorLabels" . | nindent 4 }}

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-rpc-third.selectorLabels" . | nindent 4 }}

@ -48,17 +48,17 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: webhook
containerPort: 80
protocol: TCP
#livenessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
#readinessProbe:
# httpGet:
# path: /
# port: http
# port: webhook
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:

@ -22,8 +22,8 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
targetPort: webhook
protocol: TCP
name: http
name: webhook
selector:
{{- include "openim-rpc-user.selectorLabels" . | nindent 4 }}

@ -323,7 +323,7 @@ iosPush:
# Timeout in seconds
# Whether to continue execution if callback fails
callback:
url: "http://127.0.0.1:10008/callbackExample"
url: "webhook://127.0.0.1:10008/callbackExample"
beforeSendSingleMsg:
enable: ${CALLBACK_ENABLE}
timeout: ${CALLBACK_TIMEOUT}

@ -1,298 +0,0 @@
#fixme Clone openIM Server project before using docker-compose,project addresshttps://github.com/OpenIMSDK/Open-IM-Server.git
# The command that triggers this file to pull the image is "docker compose up -f"
version: '3'
networks:
server:
driver: bridge
ipam:
driver: default
config:
- subnet: '${DOCKER_BRIDGE_SUBNET:-172.28.0.0/16}'
gateway: '${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}'
services:
mongodb:
image: mongo:${MONGODB_IMAGE_VERSION-6.0.2}
ports:
- "${MONGO_PORT:-37017}:27017"
container_name: mongo
command: ["/bin/bash", "-c", "/docker-entrypoint-initdb.d/mongo-init.sh || true; docker-entrypoint.sh mongod --wiredTigerCacheSizeGB 1 --auth"]
volumes:
- "${DATA_DIR:-./}/components/mongodb/data/db:/data/db"
- "${DATA_DIR:-./}/components/mongodb/data/logs:/data/logs"
- "${DATA_DIR:-./}/components/mongodb/data/conf:/etc/mongo"
- "./scripts/mongo-init.sh:/docker-entrypoint-initdb.d/mongo-init.sh:ro"
environment:
- TZ=Asia/Shanghai
- wiredTigerCacheSizeGB=1
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME:-root}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-openIM123}
- MONGO_INITDB_DATABASE=${MONGO_DATABASE:-openim_v3}
- MONGO_OPENIM_USERNAME=${MONGO_OPENIM_USERNAME:-openIM} # Non-root username
- MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD:-openIM123456} # Non-root password
restart: always
networks:
server:
ipv4_address: ${MONGO_NETWORK_ADDRESS:-172.28.0.2}
redis:
image: redis:${REDIS_IMAGE_VERSION:-7.0.0}
container_name: redis
ports:
- "${REDIS_PORT:-16379}:6379"
volumes:
- "${DATA_DIR:-./}/components/redis/data:/data"
- "${DATA_DIR:-./}/components/redis/config/redis.conf:/usr/local/redis/config/redis.conf"
environment:
TZ: Asia/Shanghai
restart: always
sysctls:
net.core.somaxconn: 1024
command: redis-server --requirepass ${REDIS_PASSWORD:-openIM123} --appendonly yes
networks:
server:
ipv4_address: ${REDIS_NETWORK_ADDRESS:-172.28.0.3}
zookeeper:
image: bitnami/zookeeper:${ZOOKEEPER_IMAGE_VERSION:-3.8}
container_name: zookeeper
ports:
- "${ZOOKEEPER_PORT:-12181}:2181"
volumes:
- "/etc/localtime:/etc/localtime"
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
- TZ="Asia/Shanghai"
restart: always
networks:
server:
ipv4_address: ${ZOOKEEPER_NETWORK_ADDRESS:-172.28.0.5}
kafka:
image: 'bitnami/kafka:${KAFKA_IMAGE_VERSION:-3.5.1}'
container_name: kafka
restart: always
user: ${KAFKA_USER:-root}
ports:
- "${KAFKA_PORT:-19094}:9094"
volumes:
- ./scripts/create-topic.sh:/opt/bitnami/kafka/create-topic.sh
- "${DATA_DIR:-./}/components/kafka:/bitnami/kafka"
command: >
bash -c "/opt/bitnami/scripts/kafka/run.sh & sleep 5; /opt/bitnami/kafka/create-topic.sh; wait"
environment:
- TZ=Asia/Shanghai
- KAFKA_CFG_NODE_ID=0
- KAFKA_CFG_PROCESS_ROLES=controller,broker
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@<your_host>:9093
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}:${KAFKA_PORT:-19094}
# - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://127.0.0.1:${KAFKA_PORT:-19094} # Mac Deployment
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
networks:
server:
ipv4_address: ${KAFKA_NETWORK_ADDRESS:-172.28.0.4}
minio:
image: minio/minio:${MINIO_IMAGE_VERSION:-RELEASE.2024-01-11T07-46-16Z}
ports:
- "${MINIO_PORT:-10005}:9000"
- "9090:9090"
container_name: minio
volumes:
- "${DATA_DIR:-./}/components/mnt/data:/data"
- "${DATA_DIR:-./}/components/mnt/config:/root/.minio"
environment:
MINIO_ROOT_USER: "${MINIO_ACCESS_KEY:-root}"
MINIO_ROOT_PASSWORD: "${MINIO_SECRET_KEY:-openIM123}"
restart: always
command: minio server /data --console-address ':9090'
networks:
server:
ipv4_address: ${MINIO_NETWORK_ADDRESS:-172.28.0.6}
openim-web:
image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-web:${OPENIM_WEB_IMAGE_VERSION:-v3.5.0-docker}
container_name: openim-web
platform: linux/amd64
restart: always
ports:
- "${OPENIM_WEB_PORT:-11001}:80"
networks:
server:
ipv4_address: ${OPENIM_WEB_NETWORK_ADDRESS:-172.28.0.7}
openim-admin:
# https://github.com/openimsdk/open-im-server/issues/1662
image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-admin:${ADMIN_FRONT_VERSION:-toc-base-open-docker.35}
container_name: openim-admin
platform: linux/amd64
restart: always
ports:
- "${OPENIM_ADMIN_FRONT_PORT:-11002}:80"
networks:
server:
ipv4_address: ${OPENIM_ADMIN_FRONT_NETWORK_ADDRESS:-172.28.0.13}
prometheus:
image: prom/prometheus
container_name: prometheus
hostname: prometheus
restart: always
volumes:
- "${DATA_DIR:-./}/config/instance-down-rules.yml:/etc/prometheus/instance-down-rules.yml"
- "${DATA_DIR:-./}/config/prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "${PROMETHEUS_PORT:-19090}:9090"
networks:
server:
ipv4_address: ${PROMETHEUS_NETWORK_ADDRESS:-172.28.0.10}
alertmanager:
image: prom/alertmanager
container_name: alertmanager
hostname: alertmanager
restart: always
volumes:
- ${DATA_DIR:-./}/config/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- ${DATA_DIR:-./}/config/email.tmpl:/etc/alertmanager/email.tmpl
ports:
- "${ALERT_MANAGER_PORT:-19093}:9093"
networks:
server:
ipv4_address: ${ALERT_MANAGER_NETWORK_ADDRESS:-172.28.0.14}
grafana:
image: grafana/grafana
container_name: grafana
hostname: grafana
user: root
restart: always
ports:
- "${GRAFANA_PORT:-13000}:3000"
volumes:
- "${DATA_DIR:-./}/components/grafana:/var/lib/grafana"
networks:
server:
ipv4_address: ${GRAFANA_NETWORK_ADDRESS:-172.28.0.11}
node-exporter:
image: quay.io/prometheus/node-exporter
container_name: node-exporter
hostname: node-exporter
restart: always
ports:
- "${NODE_EXPORTER_PORT:-19100}:9100"
networks:
server:
ipv4_address: ${NODE_EXPORTER_NETWORK_ADDRESS:-172.28.0.12}
### Source code deployment does not require pulling the following mirrors
# openim-server:
# image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-server:${SERVER_IMAGE_VERSION:-main}
# container_name: openim-server
# ports:
# - "${OPENIM_WS_PORT:-10001}:${OPENIM_WS_PORT:-10001}"
# - "${API_OPENIM_PORT:-10002}:${API_OPENIM_PORT:-10002}"
# - "${API_PROM_PORT:-20100}:${API_PROM_PORT:-20100}"
# - "${USER_PROM_PORT:-20110}:${USER_PROM_PORT:-20110}"
# - "${FRIEND_PROM_PORT:-20120}:${FRIEND_PROM_PORT:-20120}"
# - "${MESSAGE_PROM_PORT:-20130}:${MESSAGE_PROM_PORT:-20130}"
# - "${MSG_GATEWAY_PROM_PORT:-20140}:${MSG_GATEWAY_PROM_PORT:-20140}"
# - "${GROUP_PROM_PORT:-20150}:${GROUP_PROM_PORT:-20150}"
# - "${AUTH_PROM_PORT:-20160}:${AUTH_PROM_PORT:-20160}"
# - "${PUSH_PROM_PORT:-20170}:${PUSH_PROM_PORT:-20170}"
# - "${CONVERSATION_PROM_PORT:-20230}:${CONVERSATION_PROM_PORT:-20230}"
# - "${RTC_PROM_PORT:-21300}:${RTC_PROM_PORT:-21300}"
# - "${THIRD_PROM_PORT:-21301}:${THIRD_PROM_PORT:-21301}"
# - "21400-21403:21400-21403"
# healthcheck:
# test: ["CMD", "/openim/openim-server/scripts/check-all.sh"]
# interval: 120s
# timeout: 30s
# retries: 5
# env_file:
# - .env
# environment:
# - OPENIM_IP=${OPENIM_IP:-127.0.0.1}
# volumes:
# - "${DATA_DIR:-./}/openim-server/logs:/openim/openim-server/logs"
# - "${DATA_DIR:-./}/openim-server/_output/logs:/openim/openim-server/_output/logs"
# - "${DATA_DIR:-./}/openim-server/config:/openim/openim-server/config"
# restart: always
# depends_on:
# - kafka
# - mysql
# - mongodb
# - redis
# - minio
# logging:
# driver: json-file
# options:
# max-size: "1g"
# max-file: "2"
# networks:
# server:
# ipv4_address: ${OPENIM_SERVER_NETWORK_ADDRESS:-172.28.0.8}
### TODO: mysql is required to deploy the openim-chat component
# mysql:
# image: mysql:${MYSQL_IMAGE_VERSION:-5.7}
# platform: linux/amd64
# ports:
# - "${MYSQL_PORT:-13306}:3306"
# container_name: mysql
# volumes:
# - "${DATA_DIR:-./}/components/mysql/data:/var/lib/mysql"
# - "/etc/localtime:/etc/localtime"
# environment:
# MYSQL_ROOT_PASSWORD: "${MYSQL_PASSWORD:-openIM123}"
# restart: always
# networks:
# server:
# ipv4_address: ${MYSQL_NETWORK_ADDRESS:-172.28.0.15}
# openim-chat:
# image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-chat:${CHAT_IMAGE_VERSION:-main}
# container_name: openim-chat
# healthcheck:
# test: ["CMD", "/openim/openim-chat/scripts/check_all.sh"]
# interval: 60s
# timeout: 30s
# retries: 5
# env_file:
# - .env
# environment:
# - ZOOKEEPER_ADDRESS=${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}
# - ZOOKEEPER_PORT=${ZOOKEEPER_PORT:-12181}
# - OPENIM_SERVER_ADDRESS=http://${OPENIM_SERVER_ADDRESS:-172.28.0.1}
# - API_OPENIM_PORT=${API_OPENIM_PORT:-10002}
# - MYSQL_ADDRESS=${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}
# - MYSQL_PORT=${MYSQL_PORT:-13306}
# - REDIS_ADDRESS=${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}
# - REDIS_PORT=${REDIS_PORT:-16379}
# ports:
# - "${OPENIM_CHAT_API_PORT:-10008}:10008"
# - "${OPENIM_ADMIN_API_PORT:-10009}:10009"
# volumes:
# - "${DATA_DIR:-./}/components/openim-chat/logs:/openim/openim-chat/logs"
# - "${DATA_DIR:-./}/components/openim-chat/_output/logs:/openim/openim-chat/_output/logs"
# - "${DATA_DIR:-./}/components/openim-chat/config:/openim/openim-chat/config"
# restart: always
# # user: root:root
# depends_on:
# - mysql
# - kafka
# - redis
# - zookeeper
# logging:
# driver: json-file
# options:
# max-size: "1g"
# max-file: "2"
# networks:
# server:
# ipv4_address: ${OPENIM_CHAT_NETWORK_ADDRESS:-172.28.0.9}

@ -1,282 +1,121 @@
#fixme Clone openIM Server project before using docker-compose,project addresshttps://github.com/OpenIMSDK/Open-IM-Server.git
# The command that triggers this file to pull the image is "docker compose up -d".
version: '3'
networks:
server:
openim:
driver: bridge
ipam:
driver: default
config:
- subnet: '${DOCKER_BRIDGE_SUBNET:-172.28.0.0/16}'
gateway: '${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}'
services:
mongodb:
image: mongo:${MONGODB_IMAGE_VERSION-6.0.2}
image: "${MONGO_IMAGE}"
ports:
- "${MONGO_PORT:-37017}:27017"
- "37017:27017"
container_name: mongo
command: ["/bin/bash", "-c", "/docker-entrypoint-initdb.d/mongo-init.sh || true; docker-entrypoint.sh mongod --wiredTigerCacheSizeGB 1 --auth"]
command: ["/bin/bash", "-c", "/docker-entrypoint-initdb.d/mongo-init.sh; docker-entrypoint.sh mongod --wiredTigerCacheSizeGB 1 --auth"]
volumes:
- "${DATA_DIR:-./}/components/mongodb/data/db:/data/db"
- "${DATA_DIR:-./}/components/mongodb/data/logs:/data/logs"
- "${DATA_DIR:-./}/components/mongodb/data/conf:/etc/mongo"
- "${DATA_DIR}/components/mongodb/data/db:/data/db"
- "${DATA_DIR}/components/mongodb/data/logs:/data/logs"
- "${DATA_DIR}/components/mongodb/data/conf:/etc/mongo"
- "./scripts/mongo-init.sh:/docker-entrypoint-initdb.d/mongo-init.sh:ro"
environment:
- TZ=Asia/Shanghai
- wiredTigerCacheSizeGB=1
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME:-root}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-openIM123}
- MONGO_INITDB_DATABASE=${MONGO_DATABASE:-openim_v3}
- MONGO_OPENIM_USERNAME=${MONGO_OPENIM_USERNAME:-openIM} # Non-root username
- MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD:-openIM123456} # Non-root password
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=openIM123
- MONGO_INITDB_DATABASE=openim_v3
- MONGO_OPENIM_USERNAME=openIM
- MONGO_OPENIM_PASSWORD=openIM123
restart: always
networks:
server:
ipv4_address: ${MONGO_NETWORK_ADDRESS:-172.28.0.2}
- openim
redis:
image: redis:${REDIS_IMAGE_VERSION:-7.0.0}
image: "${REDIS_IMAGE}"
container_name: redis
ports:
- "${REDIS_PORT:-16379}:6379"
- "16379:6379"
volumes:
- "${DATA_DIR:-./}/components/redis/data:/data"
- "${DATA_DIR:-./}/components/redis/config/redis.conf:/usr/local/redis/config/redis.conf"
- "${DATA_DIR}/components/redis/data:/data"
- "${DATA_DIR}/components/redis/config/redis.conf:/usr/local/redis/config/redis.conf"
environment:
TZ: Asia/Shanghai
restart: always
sysctls:
net.core.somaxconn: 1024
command: redis-server --requirepass ${REDIS_PASSWORD:-openIM123} --appendonly yes
command: redis-server /usr/local/redis/config/redis.conf --requirepass openIM123 --appendonly yes
networks:
server:
ipv4_address: ${REDIS_NETWORK_ADDRESS:-172.28.0.3}
- openim
zookeeper:
image: bitnami/zookeeper:${ZOOKEEPER_IMAGE_VERSION:-3.8}
image: "${ZOOKEEPER_IMAGE}"
container_name: zookeeper
ports:
- "${ZOOKEEPER_PORT:-12181}:2181"
volumes:
- "/etc/localtime:/etc/localtime"
- "12181:2181"
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
- TZ="Asia/Shanghai"
TZ: "Asia/Shanghai"
ALLOW_ANONYMOUS_LOGIN: "yes"
restart: always
networks:
server:
ipv4_address: ${ZOOKEEPER_NETWORK_ADDRESS:-172.28.0.5}
- openim
kafka:
image: 'bitnami/kafka:${KAFKA_IMAGE_VERSION:-3.5.1}'
image: "${KAFKA_IMAGE}"
container_name: kafka
user: root
restart: always
user: ${KAFKA_USER:-root}
ports:
- "${KAFKA_PORT:-19094}:9094"
- "19094:9094"
volumes:
- ./scripts/create-topic.sh:/opt/bitnami/kafka/create-topic.sh
- "${DATA_DIR:-./}/components/kafka:/bitnami/kafka"
- "${DATA_DIR}/components/kafka:/bitnami/kafka"
command: >
bash -c "/opt/bitnami/scripts/kafka/run.sh & sleep 5; /opt/bitnami/kafka/create-topic.sh; wait"
bash -c "/opt/bitnami/scripts/kafka/run.sh & /opt/bitnami/kafka/create-topic.sh; wait"
environment:
- TZ=Asia/Shanghai
- KAFKA_CFG_NODE_ID=0
- KAFKA_CFG_PROCESS_ROLES=controller,broker
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@<your_host>:9093
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}:${KAFKA_PORT:-19094}
# - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://127.0.0.1:${KAFKA_PORT:-19094} # Mac Deployment
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
TZ: Asia/Shanghai
KAFKA_CFG_NODE_ID: 0
KAFKA_CFG_PROCESS_ROLES: controller,broker
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://localhost:19094
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
networks:
server:
ipv4_address: ${KAFKA_NETWORK_ADDRESS:-172.28.0.4}
- openim
minio:
image: minio/minio:${MINIO_IMAGE_VERSION:-RELEASE.2024-01-11T07-46-16Z}
image: "${MINIO_IMAGE}"
ports:
- "${MINIO_PORT:-10005}:9000"
- "9090:9090"
- "10005:9000"
- "19090:9090"
container_name: minio
volumes:
- "${DATA_DIR:-./}/components/mnt/data:/data"
- "${DATA_DIR:-./}/components/mnt/config:/root/.minio"
- "${DATA_DIR}/components/mnt/data:/data"
- "${DATA_DIR}/components/mnt/config:/root/.minio"
environment:
MINIO_ROOT_USER: "${MINIO_ACCESS_KEY:-root}"
MINIO_ROOT_PASSWORD: "${MINIO_SECRET_KEY:-openIM123}"
TZ: Asia/Shanghai
MINIO_ROOT_USER: root
MINIO_ROOT_PASSWORD: openIM123
restart: always
command: minio server /data --console-address ':9090'
networks:
server:
ipv4_address: ${MINIO_NETWORK_ADDRESS:-172.28.0.6}
- openim
openim-web:
image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-web:${OPENIM_WEB_IMAGE_VERSION:-v3.5.0-docker}
container_name: openim-web
platform: linux/amd64
openim-web-front:
image: ${OPENIM_WEB_FRONT_IMAGE}
container_name: openim-web-front
restart: always
ports:
- "${OPENIM_WEB_PORT:-11001}:80"
- "11001:80"
networks:
server:
ipv4_address: ${OPENIM_WEB_NETWORK_ADDRESS:-172.28.0.7}
- openim
openim-admin:
# https://github.com/openimsdk/open-im-server/issues/1662
image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-admin:${ADMIN_FRONT_VERSION:-toc-base-open-docker.35}
container_name: openim-admin
platform: linux/amd64
openim-admin-front:
image: ${OPENIM_ADMIN_FRONT_IMAGE}
container_name: openim-admin-front
restart: always
ports:
- "${OPENIM_ADMIN_FRONT_PORT:-11002}:80"
- "11002:80"
networks:
server:
ipv4_address: ${OPENIM_ADMIN_FRONT_NETWORK_ADDRESS:-172.28.0.13}
### TODO: Uncomment, or deploy using openim docker: https://github.com/openimsdk/openim-docker
### Uncomment and configure the following services as needed
# openim-server:
# image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-server:${SERVER_IMAGE_VERSION:-main}
# container_name: openim-server
# ports:
# - "${OPENIM_WS_PORT:-10001}:${OPENIM_WS_PORT:-10001}"
# - "${API_OPENIM_PORT:-10002}:${API_OPENIM_PORT:-10002}"
# - "${API_PROM_PORT:-20100}:${API_PROM_PORT:-20100}"
# - "${USER_PROM_PORT:-20110}:${USER_PROM_PORT:-20110}"
# - "${FRIEND_PROM_PORT:-20120}:${FRIEND_PROM_PORT:-20120}"
# - "${MESSAGE_PROM_PORT:-20130}:${MESSAGE_PROM_PORT:-20130}"
# - "${MSG_GATEWAY_PROM_PORT:-20140}:${MSG_GATEWAY_PROM_PORT:-20140}"
# - "${GROUP_PROM_PORT:-20150}:${GROUP_PROM_PORT:-20150}"
# - "${AUTH_PROM_PORT:-20160}:${AUTH_PROM_PORT:-20160}"
# - "${PUSH_PROM_PORT:-20170}:${PUSH_PROM_PORT:-20170}"
# - "${CONVERSATION_PROM_PORT:-20230}:${CONVERSATION_PROM_PORT:-20230}"
# - "${RTC_PROM_PORT:-21300}:${RTC_PROM_PORT:-21300}"
# - "${THIRD_PROM_PORT:-21301}:${THIRD_PROM_PORT:-21301}"
# - "21400-21403:21400-21403"
# healthcheck:
# test: ["CMD", "/openim/openim-server/scripts/check-all.sh"]
# interval: 120s
# timeout: 30s
# retries: 5
# env_file:
# - .env
# environment:
# - OPENIM_IP=${OPENIM_IP:-127.0.0.1}
# volumes:
# - "${DATA_DIR:-./}/openim-server/logs:/openim/openim-server/logs"
# - "${DATA_DIR:-./}/openim-server/_output/logs:/openim/openim-server/_output/logs"
# - "${DATA_DIR:-./}/openim-server/config:/openim/openim-server/config"
# restart: always
# depends_on:
# - kafka
# - mysql
# - mongodb
# - redis
# - minio
# logging:
# driver: json-file
# options:
# max-size: "1g"
# max-file: "2"
# networks:
# server:
# ipv4_address: ${OPENIM_SERVER_NETWORK_ADDRESS:-172.28.0.8}
# openim-chat:
# image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-chat:${CHAT_IMAGE_VERSION:-main}
# container_name: openim-chat
# healthcheck:
# test: ["CMD", "/openim/openim-chat/scripts/check_all.sh"]
# interval: 60s
# timeout: 30s
# retries: 5
# env_file:
# - .env
# environment:
# - ZOOKEEPER_ADDRESS=${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}
# - ZOOKEEPER_PORT=${ZOOKEEPER_PORT:-12181}
# - OPENIM_SERVER_ADDRESS=http://${OPENIM_SERVER_ADDRESS:-172.28.0.1}
# - API_OPENIM_PORT=${API_OPENIM_PORT:-10002}
# - MYSQL_ADDRESS=${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}
# - MYSQL_PORT=${MYSQL_PORT:-13306}
# - REDIS_ADDRESS=${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}
# - REDIS_PORT=${REDIS_PORT:-16379}
# ports:
# - "${OPENIM_CHAT_API_PORT:-10008}:10008"
# - "${OPENIM_ADMIN_API_PORT:-10009}:10009"
# volumes:
# - "${DATA_DIR:-./}/components/openim-chat/logs:/openim/openim-chat/logs"
# - "${DATA_DIR:-./}/components/openim-chat/_output/logs:/openim/openim-chat/_output/logs"
# - "${DATA_DIR:-./}/components/openim-chat/config:/openim/openim-chat/config"
# restart: always
# # user: root:root
# depends_on:
# - mysql
# - kafka
# - redis
# - zookeeper
# logging:
# driver: json-file
# options:
# max-size: "1g"
# max-file: "2"
# networks:
# server:
# ipv4_address: ${OPENIM_CHAT_NETWORK_ADDRESS:-172.28.0.9}
# prometheus:
# image: prom/prometheus
# container_name: prometheus
# hostname: prometheus
# restart: always
# volumes:
# - "${DATA_DIR:-./}/config/instance-down-rules.yml:/etc/prometheus/instance-down-rules.yml"
# - "${DATA_DIR:-./}/config/prometheus.yml:/etc/prometheus/prometheus.yml"
# ports:
# - "${PROMETHEUS_PORT:-19090}:9090"
# networks:
# server:
# ipv4_address: ${PROMETHEUS_NETWORK_ADDRESS:-172.28.0.10}
# alertmanager:
# image: prom/alertmanager
# container_name: alertmanager
# hostname: alertmanager
# restart: always
# volumes:
# - ${DATA_DIR:-./}/config/alertmanager.yml:/etc/alertmanager/alertmanager.yml
# - ${DATA_DIR:-./}/config/email.tmpl:/etc/alertmanager/email.tmpl
# ports:
# - "${ALERT_MANAGER_PORT:-19093}:9093"
# networks:
# server:
# ipv4_address: ${ALERT_MANAGER_NETWORK_ADDRESS:-172.28.0.14}
- openim
# grafana:
# image: grafana/grafana
# container_name: grafana
# hostname: grafana
# user: root
# restart: always
# ports:
# - "${GRAFANA_PORT:-13000}:3000"
# volumes:
# - "${DATA_DIR:-./}/components/grafana:/var/lib/grafana"
# networks:
# server:
# ipv4_address: ${GRAFANA_NETWORK_ADDRESS:-172.28.0.11}
# node-exporter:
# image: quay.io/prometheus/node-exporter
# container_name: node-exporter
# hostname: node-exporter
# restart: always
# ports:
# - "${NODE_EXPORTER_PORT:-19100}:9100"
# networks:
# server:
# ipv4_address: ${NODE_EXPORTER_NETWORK_ADDRESS:-172.28.0.12}

@ -115,22 +115,83 @@ var s = F()
func F() string { return "A" }
```
- Use `_` as a prefix for unexported top-level constants and variables.
- This example emphasizes using PascalCase for exported constants and camelCase for unexported ones, avoiding all caps and underscores.
```go
// bad
const (
defaultHost = "127.0.0.1"
defaultPort = 8080
MAX_COUNT = 100
timeout = 30
)
// good
const (
_defaultHost = "127.0.0.1"
_defaultPort = 8080
MaxCount = 100 // Exported constants should use PascalCase.
defaultTimeout = 30 // Unexported constants should use camelCase.
)
```
- Grouping related constants enhances organization and readability, especially when there are multiple constants related to a particular feature or configuration.
```go
// bad
const apiVersion = "v1"
const retryInterval = 5
// good
const (
ApiVersion = "v1" // Group related constants together for better organization.
RetryInterval = 5
)
```
- The "good" practice utilizes iota for a clear, concise, and auto-incrementing way to define enumerations, reducing the potential for errors and improving maintainability.
```go
// bad
const (
StatusActive = 0
StatusInactive = 1
StatusUnknown = 2
)
// good
const (
StatusActive = iota // Use iota for simple and efficient constant enumerations.
StatusInactive
StatusUnknown
)
```
- Specifying types explicitly improves clarity, especially when the purpose or type of a constant might not be immediately obvious. Additionally, adding comments to exported constants or those whose purpose isn't clear from the name alone can greatly aid in understanding the code.
```go
// bad
const serverAddress = "localhost:8080"
const debugMode = 1 // Is this supposed to be a boolean or an int?
// good
const ServerAddress string = "localhost:8080" // Specify type for clarity.
// DebugMode indicates if the application should run in debug mode (true for debug mode).
const DebugMode bool = true
```
- By defining a contextKey type and making userIDKey of this type, you avoid potential collisions with other context keys. This approach leverages Go's type system to provide compile-time checks against misuse.
```go
// bad
const userIDKey = "userID"
// In this example, userIDKey is a string type, which can lead to conflicts or accidental misuse because string keys are prone to typos and collisions in a global namespace.
// good
type contextKey string
const userIDKey contextKey = "userID"
```
- Embedded types (such as mutexes) should be at the top of the field list within the struct, and there must be a blank line separating embedded fields from regular fields.
```go
@ -274,8 +335,6 @@ The use of `panic` should be carefully controlled in Go applications to ensure p
- **Restricted Use in Main Package:** In the main package, the use of `panic` should be reserved for situations where the program is entirely inoperable, such as failure to open essential files, inability to connect to the database, or other critical startup issues. Even in these scenarios, prefer using structured error handling to terminate the program.
- **Use `log.Fatal` for Critical Errors:** Instead of panicking, use `log.Fatal` to log critical errors that prevent the program from operating normally. This approach allows the program to terminate while ensuring the error is properly logged for troubleshooting.
- **Prohibition on Exportable Interfaces:** Exportable interfaces must not invoke `panic`. They should handle errors gracefully and return errors as part of their contract.
- **Prefer Errors Over Panic:** It is recommended to use error returns instead of panic to convey errors within a package. This approach promotes error handling that integrates smoothly with Go's error handling idioms.
@ -303,7 +362,7 @@ func SIGTERMExit() {
```go
import (
_ "net/http/pprof"
_ "net/webhook/pprof"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
@ -357,27 +416,31 @@ The naming convention is a very important part of the code specification. A unif
- Don't use broad, meaningless package names like common, util, shared or lib.
- The package name should be simple and clear, such as net, time, log.
### 2.2 Function Naming
- The function name is in camel case, and the first letter is uppercase or lowercase according to the access control decision,For example: `MixedCaps` or `mixedCaps`.
- Code automatically generated by code generation tools (such as `xxxx.pb.go`) and underscores used to group related test cases (such as `TestMyFunction_WhatIsBeingTested`) exclude this rule.
### 2.2 Function Naming Conventions
Function names should adhere to the following guidelines, inspired by OpenIMs standards and Googles Go Style Guide:
- Use camel case for function names. Start with an uppercase letter for public functions (`MixedCaps`) and a lowercase letter for private functions (`mixedCaps`).
- Exceptions to this rule include code automatically generated by tools (e.g., `xxxx.pb.go`) and test functions that use underscores for clarity (e.g., `TestMyFunction_WhatIsBeingTested`).
### 2.3 File and Directory Naming Practices
To maintain consistency and readability across the OpenIM project, observe the following naming practices:
**File Names:**
- Use underscores (`_`) as the default separator in filenames, keeping them short and descriptive.
- Both hyphens (`-`) and underscores (`_`) are allowed, but underscores are preferred for general use.
In accordance with the naming conventions adopted by OpenIM and drawing reference from the Google Naming Conventions as per the guidelines available at https://google.github.io/styleguide/go/, the following expectations for naming practices within the project are set forth:
**Script and Markdown Files:**
- Prefer hyphens (`-`) for shell scripts and Markdown (`.md`) files to enhance searchability and web compatibility.
1. **File Names:**
+ Both hyphens (`-`) and underscores (`_`) are permitted when naming files.
+ A preference is established for the use of underscores (`_`), suggesting it as the best practice in general scenarios.
2. **Script and Markdown Files:**
+ For shell scripts (bash files) and Markdown (`.md`) documents, the use of hyphens (`-`) is recommended.
+ This recommendation is based on the improved searchability and compatibility in web browsers when hyphens are used in names.
3. **Directories:**
+ A consistent approach is mandated for naming directories, exclusively using hyphens (`-`) to separate words within directory names.
**Directories:**
- Name directories with hyphens (`-`) exclusively to separate words, ensuring consistency and readability.
Remember to keep filenames lowercase and use meaningful, concise identifiers to facilitate better organization and navigation within the project.
### 2.3 File Naming
- Keep the filename short and meaningful.
- Filenames should be lowercase and use underscores to separate words.
### 2.4 Structure Naming

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save