feat: add config path config

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
pull/825/head
Xinwei Xiong(cubxxw-openim) 2 years ago
parent d9e4899da5
commit 2d035f0029
No known key found for this signature in database
GPG Key ID: 1BAD6F395338EFDE

@ -114,7 +114,7 @@ api:
openImApiPort: [ 10002 ]
listenIP: 0.0.0.0
###################### Gateway ######################
###################### Object ######################
# Object storage configuration
#
# Use minio for object storage
@ -165,7 +165,6 @@ rpcPort:
openImConversationPort: [ 10180 ]
openImThirdPort: [ 10190 ]
# RPC service names for registration, it's not recommended to modify these
rpcRegisterName:
openImUserName: User
openImFriendName: Friend
@ -177,15 +176,6 @@ rpcRegisterName:
openImConversationName: Conversation
openImThirdName: Third
# Log configuration
#
# Storage directory
# Log rotation time
# Maximum number of logs to retain
# Log level, 6 means all levels
# Whether to output to stdout
# Whether to output in json format
# Whether to include stack trace in logs
log:
storageLocation: ../../../../../logs/
rotationTime: 24
@ -195,25 +185,12 @@ log:
isJson: false
withStack: false
# Long connection server configuration
#
# Websocket port for msg_gateway
# Maximum number of websocket connections
# Maximum length of websocket request package
# Websocket connection handshake timeout
longConnSvr:
openImWsPort: [ 10001 ]
websocketMaxConnNum: 100000
websocketMaxMsgLen: 4096
websocketTimeout: 10
# Push notification service configuration
#
# Use GeTui for push notifications
# GeTui offline push configuration
# FCM offline push configuration
# Account file, place it in the config directory
# JPush configuration, modify these after applying in JPush backend
push:
enable: getui
geTui:
@ -231,61 +208,34 @@ push:
pushUrl:
pushIntent:
# App manager configuration
#
# Built-in app manager user IDs
# Built-in app manager nicknames
manager:
userID: [ "openIM123456","openIM654321","openIMAdmin" ]
nickname: [ "system1","system2", "system3" ]
# Multi-platform login policy
# For each platform(Android, iOS, Windows, Mac, web), only one can be online at a time
multiLoginPolicy: 1
# Whether to store messages in MySQL, messages in MySQL are only used for management background
chatPersistenceMysql: true
# Message cache timeout in seconds, it's not recommended to modify
msgCacheTimeout: 86400
# Whether to enable read receipts for group chat
groupMessageHasReadReceiptEnable: true
# Whether to enable read receipts for single chat
singleMessageHasReadReceiptEnable: true
# MongoDB offline message retention period in days
retainChatRecords: 365
# Schedule to clear expired messages(older than retainChatRecords days) in MongoDB every Wednesday at 2am
# This deletion is just for cleaning up disk usage according to previous configuration retainChatRecords, no notification will be sent
chatRecordsClearTime: "0 2 * * 3"
# Schedule to auto delete messages every day at 2am
# This deletion is for messages that have been retained for more than msg_destruct_time (seconds) in the conversation field
msgDestructTime: "0 2 * * *"
# Secret key
secret: openIM123
# Token policy
#
# Token expiration period in days
tokenPolicy:
expire: 90
# Message verification policy
#
# Whether to verify friendship when sending messages
messageVerify:
friendVerify: false
# iOS push notification configuration
#
# iOS push notification sound
# Whether to count badge
# Whether it's production environment
iosPush:
pushSound: "xxx"
badgeCount: true

@ -128,6 +128,11 @@ services:
image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:latest
# image: openim/openim-chat:latest
container_name: openim-chat
healthcheck:
test: ["CMD-SHELL", "./scripts/check_all.sh"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- ${DATA_DIR}/_output/openim/openim-chat/logs:/openim/openim-chat/logs
- ${DATA_DIR}/_output/openim/openim-chat/config:/openim/openim-chat/config

@ -0,0 +1,74 @@
# Init OpenIM Config
- [Init OpenIM Config](#init-openim-config)
- [Start](#start)
- [Define Automated Configuration](#define-automated-configuration)
- [Define Configuration Variables](#define-configuration-variables)
- [Bash Parsing Features](#bash-parsing-features)
- [Reasons and Advantages of the Design](#reasons-and-advantages-of-the-design)
## Start
With the increasing complexity of software engineering, effective configuration management has become more and more important. Yaml and other configuration files provide the necessary parameters and guidance for systems, but they also impose additional management overhead for developers. This article explores how to automate and optimize configuration management, thereby improving efficiency and reducing the chances of errors.
First, obtain the OpenIM code through the contributor documentation and initialize it following the steps below.
## Define Automated Configuration
We no longer strongly recommend modifying the same configuration file. If you have a new configuration file related to your business, we suggest generating and managing it through automation.
In the `scripts/init_config.sh` file, we defined some template files. These templates will be automatically generated to the corresponding directories when executing `make init`.
```
# Defines an associative array where the keys are the template files and the values are the corresponding output files.
declare -A TEMPLATES=(
["${OPENIM_ROOT}/scripts/template/config-tmpl/env.template"]="${OPENIM_OUTPUT_SUBPATH}/bin/.env"
["${OPENIM_ROOT}/scripts/template/config-tmpl/openim_config.yaml"]="${OPENIM_OUTPUT_SUBPATH}/bin/openim_config.yaml"
)
```
If you have your new mapping files, you can implement them by appending them to the array.
Lastly, run:
```
./scripts/init_config.sh
```
## Define Configuration Variables
In the `scripts/install/environment.sh` file, we defined many reusable variables for automation convenience.
In the provided example, the def function is a core element. This function not only provides a concise way to define variables but also offers default value options for each variable. This way, even if a specific variable is not explicitly set in an environment or scenario, it can still have an expected value.
```
function def() {
local var_name="$1"
local default_value="$2"
eval "readonly $var_name=\${$var_name:-$default_value}"
}
```
### Bash Parsing Features
Since bash is a parsing script language, it executes commands in the order they appear in the script. This characteristic means we can define commonly used or core variables at the beginning of the script and then reuse or modify them later on.
For instance, we can initially set a universal password and reuse this password in subsequent variable definitions.
```
# Set a consistent password for easy memory
def "PASSWORD" "openIM123"
# Linux system user for openim
def "LINUX_USERNAME" "openim"
def "LINUX_PASSWORD" "${PASSWORD}"
```
## Reasons and Advantages of the Design
1. **Simplify Configuration Management**: Through automation scripts, we can avoid manual operations and configurations, thus reducing tedious repetitive tasks.
2. **Reduce Errors**: Manually editing yaml or other configuration files can lead to formatting mistakes or typographical errors. Automating with scripts can lower the risk of such errors.
3. **Enhanced Readability**: Using the `def` function and other bash scripting techniques, we can establish a clear, easy-to-read, and maintainable configuration system.
4. **Improved Reusability**: As demonstrated above, we can reuse variables and functions in different parts of the script, reducing redundant code and increasing overall consistency.
5. **Flexible Default Value Mechanism**: By providing default values for variables, we can ensure configurations are complete and consistent across various scenarios, while also offering customization options for advanced users.

@ -0,0 +1,14 @@
# act
Run your [GitHub Actions](https://developer.github.com/actions/) locally! Why would you want to do this? Two reasons:
- **Fast Feedback** - Rather than having to commit/push every time you want to test out the changes you are making to your `.github/workflows/` files (or for any changes to embedded GitHub actions), you can use `act` to run the actions locally. The [environment variables](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables) and [filesystem](https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners) are all configured to match what GitHub provides.
- **Local Task Runner** - I love [make](https://en.wikipedia.org/wiki/Make_(software)). However, I also hate repeating myself. With `act`, you can use the GitHub Actions defined in your `.github/workflows/` to replace your `Makefile`!
## install act
+ [https://github.com/nektos/act](https://github.com/nektos/act)
```bash
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
···

@ -23,7 +23,7 @@ set -o pipefail
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh"
cd $SCRIPTS_ROOT
trap 'openim::util::onCtrlC' INT
need_to_start_server_shell=(
"start_rpc_service.sh"

@ -42,6 +42,7 @@ service_port_name=(
openImConversationPort
openImThirdPort
)
for i in ${service_port_name[*]}; do
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
openim::util::list-to-string $list

@ -16,6 +16,8 @@
clear
. $(dirname ${BASH_SOURCE})/lib/util.sh
trap 'openim::util::onCtrlC' INT
openim::util::desc "========> Welcome to the OpenIM Demo"
openim::util::desc "========> We'll help you get started with OpenIM quickly"
openim::util::desc "========> Press Enter to continue...."

@ -22,9 +22,7 @@ source "$SCRIPTS_ROOT/style_info.sh"
echo -e "${GREEN_PREFIX}=========> Check docker-compose status ${COLOR_SUFFIX} \n"
trap 'onCtrlC' INT
function onCtrlC() {
function openim::util::onCtrlC() {
kill -9 "${do_sth_pid}" "${progress_pid}" "${countdown_pid}"
echo
echo 'Ctrl+C is captured'

@ -21,6 +21,8 @@
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
trap 'openim::util::onCtrlC' INT
#fixme Put the shell scripts name here
need_to_start_server_shell=(
${SCRIPTS_ROOT}/start_rpc_service.sh

@ -15,6 +15,7 @@
# 本脚本功能:根据 scripts/environment.sh 配置,生成 OPENIM 组件 YAML 配置文件。
# 示例:./scripts/genconfig.sh scripts/install/environment.sh scripts/template/openim_config.yaml
# Read: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/contrib/init_config.md
# Path to the original script file
env_file="$1"
@ -24,8 +25,7 @@ template_file="$2"
. $(dirname ${BASH_SOURCE})/lib/init.sh
if [ $# -ne 2 ];then
openim::log::error "Usage: genconfig.sh scripts/environment.sh configs/openim-api.yaml"
exit 1
openim::log::error_exit "Usage: genconfig.sh scripts/environment.sh configs/openim-api.yaml"
fi
source "${env_file}"

@ -0,0 +1,50 @@
#!/usr/bin/env bash
# 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.
# This script automatically initializes the various configuration files
# Read: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/contrib/init_config.md
set -o errexit
set -o nounset
set -o pipefail
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh"
# 定义一个配置文件数组,其中包含需要生成的配置文件的名称路径 (en: Define a profile array that contains the name path of the profile to be generated.)
readonly ENV_FILE=${ENV_FILE:-${OPENIM_ROOT}/scripts/install/environment.sh}
# 定义关联数组,其中键是模板文件,值是对应的输出文件 (en: Defines an associative array where the keys are the template files and the values are the corresponding output files.)
declare -A TEMPLATES=(
["${OPENIM_ROOT}/scripts/template/config-tmpl/env.template"]="${OPENIM_OUTPUT_SUBPATH}/bin/.env"
["${OPENIM_ROOT}/scripts/template/config-tmpl/openim_config.yaml"]="${OPENIM_OUTPUT_SUBPATH}/bin/openim_config.yaml"
)
for template in "${!TEMPLATES[@]}"; do
output_file=${TEMPLATES[$template]}
if [[ ! -f "${template}" ]]; then
openim::log::error_exit "template file ${template} does not exist..."
fi
openim::log::info "Working with template file: ${template} to ${output_file}..."
"${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || {
openim::log::error "Error processing template file ${template}"
exit 1
}
done
openim::log::success "All configuration files have been successfully generated!"

@ -13,107 +13,212 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# This is a file that initializes variables for the automation script that initializes the config file
# You need to supplement the script according to the specification.
# Read: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/contrib/init_config.md
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
# 生成文件存放目录
LOCAL_OUTPUT_ROOT="${OPENIM_ROOT}/${OUT_DIR:-_output}"
# 定义只读变量,如果变量未定义,则使用默认值
function def() {
local var_name="$1"
local default_value="$2"
eval "readonly $var_name=\${$var_name:-$default_value}"
}
# app要能访问到此ip和端口或域名
readonly API_URL=${API_URL:-http://127.0.0.1:10002/object/}
readonly DATA_DIR=${DATA_DIR:-${OPENIM_ROOT}}
def "API_URL" "http://127.0.0.1:10002/object/"
def "DATA_DIR" "${OPENIM_ROOT}"
# 设置统一的用户名,方便记忆
readonly USER=${USER:-'root'} # Setting a username
def "USER" "root"
# 设置统一的密码,方便记忆
readonly PASSWORD=${PASSWORD:-'openIM123'} # Setting a password
def "PASSWORD" "openIM123"
# Linux系统 openim 用户
readonly LINUX_USERNAME=${LINUX_USERNAME:-openim}
# Linux root & openim 用户密码
readonly LINUX_PASSWORD=${LINUX_PASSWORD:-${PASSWORD}}
def "LINUX_USERNAME" "openim"
def "LINUX_PASSWORD" "${PASSWORD}"
# 设置安装目录
readonly INSTALL_DIR=${INSTALL_DIR:-/tmp/installation}
def "INSTALL_DIR" "${LOCAL_OUTPUT_ROOT}/installs"
mkdir -p ${INSTALL_DIR}
readonly ENV_FILE=${OPENIM_ROOT}/scripts/install/environment.sh
# MINIO 配置信息
readonly OBJECT_ENABLE=${OBJECT_ENABLE:-minio}
readonly OBJECT_APIURL=${OBJECT_APIURL:-http://127.0.0.1:10002/object/}
readonly MINIO_BUCKET=${MINIO_BUCKET:-openim}
readonly MINIO_ENDPOINT=${MINIO_ENDPOINT:-http://127.0.0.1:10005}
readonly MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-root}
readonly MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-openIM123}
readonly COS_BUCKET_URL=${COS_BUCKET_URL:-https://temp-1252357374.cos.ap-chengdu.myqcloud.com}
readonly OSS_ENDPOINT=${OSS_ENDPOINT:-http://oss-cn-chengdu.aliyuncs.com}
readonly OSS_BUCKET=${OSS_BUCKET:-demo-9999999}
readonly OSS_BUCKET_URL=${OSS_BUCKET_URL:-https://demo-9999999.oss-cn-chengdu.aliyuncs.com}
readonly OSS_ACCESS_KEY_ID=${OSS_ACCESS_KEY_ID:-root}
# MariaDB 配置信息
readonly MARIADB_ADMIN_USERNAME=${MARIADB_ADMIN_USERNAME:-root} # MariaDB root 用户
readonly MARIADB_ADMIN_PASSWORD=${MARIADB_ADMIN_PASSWORD:-${PASSWORD}} # MariaDB root 用户密码
readonly MARIADB_HOST=${MARIADB_HOST:-127.0.0.1:3306} # MariaDB 主机地址
readonly MARIADB_DATABASE=${MARIADB_DATABASE:-openim} # MariaDB openim 应用使用的数据库名
readonly MARIADB_USERNAME=${MARIADB_USERNAME:-openim} # openim 数据库用户名
readonly MARIADB_PASSWORD=${MARIADB_PASSWORD:-${PASSWORD}} # openim 数据库密码
# Redis 配置信息
readonly REDIS_HOST=${REDIS_HOST:-127.0.0.1} # Redis 主机地址
readonly REDIS_PORT=${REDIS_PORT:-6379} # Redis 监听端口
readonly REDIS_USERNAME=${REDIS_USERNAME:-''} # Redis 用户名
readonly REDIS_PASSWORD=${REDIS_PASSWORD:-${PASSWORD}} # Redis 密码
# MongoDB 配置
readonly MONGO_ADMIN_USERNAME=${MONGO_ADMIN_USERNAME:-root} # MongoDB root 用户
readonly MONGO_ADMIN_PASSWORD=${MONGO_ADMIN_PASSWORD:-${PASSWORD}} # MongoDB root 用户密码
readonly MONGO_HOST=${MONGO_HOST:-127.0.0.1} # MongoDB 地址
readonly MONGO_PORT=${MONGO_PORT:-27017} # MongoDB 端口
readonly MONGO_USERNAME=${MONGO_USERNAME:-openim} # MongoDB 用户名
readonly MONGO_PASSWORD=${MONGO_PASSWORD:-${PASSWORD}} # MongoDB 密码
def "ENV_FILE" "${OPENIM_ROOT}/scripts/install/environment.sh"
###################### Zookeeper 配置信息 ######################
def "ZOOKEEPER_SCHEMA" "openim" # Zookeeper的模式
def "ZOOKEEPER_ADDRESS" "127.0.0.1:2181" # Zookeeper的地址
def "ZOOKEEPER_USERNAME" "" # Zookeeper的用户名
def "ZOOKEEPER_PASSWORD" "" # Zookeeper的密码
###################### MySQL 配置信息 ######################
def "MYSQL_ADDRESS" "127.0.0.1:13306" # MySQL的地址
def "MYSQL_USERNAME" "root" # MySQL的用户名
def "MYSQL_PASSWORD" "openIM123" # MySQL的密码
def "MYSQL_DATABASE" "openIM_v3" # MySQL的数据库名
def "MYSQL_MAX_OPEN_CONN" "1000" # 最大打开的连接数
def "MYSQL_MAX_IDLE_CONN" "100" # 最大空闲连接数
def "MYSQL_MAX_LIFETIME" "60" # 连接可以重用的最大生命周期(秒)
def "MYSQL_LOG_LEVEL" "4" # 日志级别
def "MYSQL_SLOW_THRESHOLD" "500" # 慢查询阈值(毫秒)
###################### MongoDB 配置信息 ######################
def "MONGO_URI" "" # MongoDB的URI
def "MONGO_ADDRESS" "127.0.0.1:37017" # MongoDB的地址
def "MONGO_DATABASE" "openIM_v3" # MongoDB的数据库名
def "MONGO_USERNAME" "root" # MongoDB的用户名
def "MONGO_PASSWORD" "openIM123" # MongoDB的密码
def "MONGO_MAX_POOL_SIZE" "100" # 最大连接池大小
###################### Object 配置信息 ######################
def "OBJECT_ENABLE" "minio" # 对象是否启用
def "OBJECT_APIURL" "http://127.0.0.1:10002/object/" # 对象的API地址
def "MINIO_BUCKET" "openim" # MinIO的存储桶名称
def "MINIO_ENDPOINT" "http://127.0.0.1:10005" # MinIO的端点URL
def "MINIO_ACCESS_KEY" "root" # MinIO的访问密钥ID
def "MINIO_SECRET_KEY" "openIM123" # MinIO的密钥
def "MINIO_SESSION_TOKEN" "" # MinIO的会话令牌
def "COS_BUCKET_URL" "https://temp-1252357374.cos.ap-chengdu.myqcloud.com" # 腾讯云COS的存储桶URL
def "COS_SECRET_ID" "" # 腾讯云COS的密钥ID
def "COS_SECRET_KEY" "" # 腾讯云COS的密钥
def "COS_SESSION_TOKEN" "" # 腾讯云COS的会话令牌
def "OSS_ENDPOINT" "https://oss-cn-chengdu.aliyuncs.com" # 阿里云OSS的端点URL
def "OSS_BUCKET" "demo-9999999" # 阿里云OSS的存储桶名称
def "OSS_BUCKET_URL" "https://demo-9999999.oss-cn-chengdu.aliyuncs.com" # 阿里云OSS的存储桶URL
def "OSS_ACCESS_KEY_ID" "root" # 阿里云OSS的访问密钥ID
def "OSS_ACCESS_KEY_SECRET" "" # 阿里云OSS的密钥
def "OSS_SESSION_TOKEN" "" # 阿里云OSS的会话令牌
###################### Redis 配置信息 ######################
def "REDIS_ADDRESS" "127.0.0.1:16379" # Redis的地址
def "REDIS_USERNAME" "" # Redis的用户名
def "REDIS_PASSWORD" "openIM123" # Redis的密码
###################### Kafka 配置信息 ######################
def "KAFKA_USERNAME" "" # Kafka的用户名
def "KAFKA_PASSWORD" "" # Kafka的密码
def "KAFKA_ADDR" "127.0.0.1:9092" # Kafka的地址
def "KAFKA_LATESTMSG_REDIS_TOPIC" "latestMsgToRedis" # Kafka的最新消息到Redis的主题
def "KAFKA_OFFLINEMSG_MONGO_TOPIC" "offlineMsgToMongoMysql" # Kafka的离线消息到Mongo的主题
def "KAFKA_MSG_PUSH_TOPIC" "msgToPush" # Kafka的消息到推送的主题
def "KAFKA_CONSUMERGROUPID_REDIS" "redis" # Kafka的消费组ID到Redis
def "KAFKA_CONSUMERGROUPID_MONGO" "mongo" # Kafka的消费组ID到Mongo
def "KAFKA_CONSUMERGROUPID_MYSQL" "mysql" # Kafka的消费组ID到MySql
def "KAFKA_CONSUMERGROUPID_PUSH" "push" # Kafka的消费组ID到推送
###################### RPC 配置信息 ######################
def "RPC_REGISTER_IP" "" # RPC的注册IP
def "RPC_LISTEN_IP" "0.0.0.0" # RPC的监听IP
###################### API 配置信息 ######################
def "API_OPENIM_PORT" "10002" # API的开放端口
def "API_LISTEN_IP" "0.0.0.0" # API的监听IP
###################### RPC Port Configuration Variables ######################
def "OPENIM_USER_PORT" "10110" # OpenIM用户服务端口
def "OPENIM_FRIEND_PORT" "10120" # OpenIM朋友服务端口
def "OPENIM_MESSAGE_PORT" "10130" # OpenIM消息服务端口
def "OPENIM_MESSAGE_GATEWAY_PORT" "10140" # OpenIM消息网关服务端口
def "OPENIM_GROUP_PORT" "10150" # OpenIM组服务端口
def "OPENIM_AUTH_PORT" "10160" # OpenIM授权服务端口
def "OPENIM_PUSH_PORT" "10170" # OpenIM推送服务端口
def "OPENIM_CONVERSATION_PORT" "10180" # OpenIM对话服务端口
def "OPENIM_THIRD_PORT" "10190" # OpenIM第三方服务端口
###################### RPC Register Name Variables ######################
def "OPENIM_USER_NAME" "User" # OpenIM用户服务名称
def "OPENIM_FRIEND_NAME" "Friend" # OpenIM朋友服务名称
def "OPENIM_MSG_NAME" "Msg" # OpenIM消息服务名称
def "OPENIM_PUSH_NAME" "Push" # OpenIM推送服务名称
def "OPENIM_MESSAGE_GATEWAY_NAME" "MessageGateway" # OpenIM消息网关服务名称
def "OPENIM_GROUP_NAME" "Group" # OpenIM组服务名称
def "OPENIM_AUTH_NAME" "Auth" # OpenIM授权服务名称
def "OPENIM_CONVERSATION_NAME" "Conversation" # OpenIM对话服务名称
def "OPENIM_THIRD_NAME" "Third" # OpenIM第三方服务名称
###################### Log Configuration Variables ######################
def "LOG_STORAGE_LOCATION" "../../../../../logs/" # 日志存储位置
def "LOG_ROTATION_TIME" "24" # 日志轮替时间
def "LOG_REMAIN_ROTATION_COUNT" "2" # 保留的日志轮替数量
def "LOG_REMAIN_LOG_LEVEL" "6" # 保留的日志级别
def "LOG_IS_STDOUT" "false" # 是否将日志输出到标准输出
def "LOG_IS_JSON" "false" # 日志是否为JSON格式
def "LOG_WITH_STACK" "false" # 日志是否带有堆栈信息
###################### Variables definition ######################
def "OPENIM_WS_PORT" "10001" # OpenIM WS端口
def "WEBSOCKET_MAX_CONN_NUM" "100000" # Websocket最大连接数
def "WEBSOCKET_MAX_MSG_LEN" "4096" # Websocket最大消息长度
def "WEBSOCKET_TIMEOUT" "10" # Websocket超时
def "PUSH_ENABLE" "getui" # 推送是否启用
def "GETUI_PUSH_URL" "https://restapi.getui.com/v2/$appId" # GeTui推送URL
def "FCM_SERVICE_ACCOUNT" "x.json" # FCM服务账户
def "JPNS_APP_KEY" "" # JPNS应用密钥
def "JPNS_MASTER_SECRET" "" # JPNS主密钥
def "JPNS_PUSH_URL" "" # JPNS推送URL
def "JPNS_PUSH_INTENT" "" # JPNS推送意图
def "MANAGER_USERID_1" "openIM123456" # 管理员ID 1
def "MANAGER_USERID_2" "openIM654321" # 管理员ID 2
def "MANAGER_USERID_3" "openIMAdmin" # 管理员ID 3
def "NICKNAME_1" "system1" # 昵称1
def "NICKNAME_2" "system2" # 昵称2
def "NICKNAME_3" "system3" # 昵称3
def "MULTILOGIN_POLICY" "1" # 多登录策略
def "CHAT_PERSISTENCE_MYSQL" "true" # 聊天持久化MySQL
def "MSG_CACHE_TIMEOUT" "86400" # 消息缓存超时
def "GROUP_MSG_READ_RECEIPT" "true" # 群消息已读回执启用
def "SINGLE_MSG_READ_RECEIPT" "true" # 单一消息已读回执启用
def "RETAIN_CHAT_RECORDS" "365" # 保留聊天记录
def "CHAT_RECORDS_CLEAR_TIME" "0 2 * * 3" # 聊天记录清理时间
def "MSG_DESTRUCT_TIME" "0 2 * * *" # 消息销毁时间
def "SECRET" "openIM123" # 密钥
def "TOKEN_EXPIRE" "90" # Token到期时间
def "FRIEND_VERIFY" "false" # 朋友验证
def "IOS_PUSH_SOUND" "xxx" # IOS推送声音
def "IOS_BADGE_COUNT" "true" # IOS徽章计数
def "IOS_PRODUCTION" "false" # IOS生产
###################### Prometheus 配置信息 ######################
def "PROMETHEUS_ENABLE" "false" # 是否启用 Prometheus
def "USER_PROM_PORT" "20110" # User 服务的 Prometheus 端口
def "FRIEND_PROM_PORT" "20120" # Friend 服务的 Prometheus 端口
def "MESSAGE_PROM_PORT" "20130" # Message 服务的 Prometheus 端口
def "MSG_GATEWAY_PROM_PORT" "20140" # Message Gateway 服务的 Prometheus 端口
def "GROUP_PROM_PORT" "20150" # Group 服务的 Prometheus 端口
def "AUTH_PROM_PORT" "20160" # Auth 服务的 Prometheus 端口
def "PUSH_PROM_PORT" "20170" # Push 服务的 Prometheus 端口
def "CONVERSATION_PROM_PORT" "20230" # Conversation 服务的 Prometheus 端口
def "RTC_PROM_PORT" "21300" # RTC 服务的 Prometheus 端口
def "THIRD_PROM_PORT" "21301" # Third 服务的 Prometheus 端口
def "MSG_TRANSFER_PROM_PORTS" "21400, 21401, 21402, 21403" # Message Transfer 服务的 Prometheus 端口列表
# openim 配置
readonly OPENIM_DATA_DIR=${OPENIM_DATA_DIR:-/data/openim} # openim 各组件数据目录
readonly OPENIM_INSTALL_DIR=${OPENIM_INSTALL_DIR:-/opt/openim} # openim 安装文件存放目录
readonly OPENIM_CONFIG_DIR=${OPENIM_CONFIG_DIR:-/etc/openim} # openim 配置文件存放目录
readonly OPENIM_LOG_DIR=${OPENIM_LOG_DIR:-/var/log/openim} # openim 日志文件存放目录
readonly CA_FILE=${CA_FILE:-${OPENIM_CONFIG_DIR}/cert/ca.pem} # CA
# openim-apiserver 配置
readonly OPENIM_APISERVER_HOST=${OPENIM_APISERVER_HOST:-127.0.0.1} # openim-apiserver 部署机器 IP 地址
readonly OPENIM_APISERVER_GRPC_BIND_ADDRESS=${OPENIM_APISERVER_GRPC_BIND_ADDRESS:-0.0.0.0}
readonly OPENIM_APISERVER_GRPC_BIND_PORT=${OPENIM_APISERVER_GRPC_BIND_PORT:-8081}
readonly OPENIM_APISERVER_INSECURE_BIND_ADDRESS=${OPENIM_APISERVER_INSECURE_BIND_ADDRESS:-127.0.0.1}
readonly OPENIM_APISERVER_INSECURE_BIND_PORT=${OPENIM_APISERVER_INSECURE_BIND_PORT:-8080}
readonly OPENIM_APISERVER_SECURE_BIND_ADDRESS=${OPENIM_APISERVER_SECURE_BIND_ADDRESS:-0.0.0.0}
readonly OPENIM_APISERVER_SECURE_BIND_PORT=${OPENIM_APISERVER_SECURE_BIND_PORT:-8443}
readonly OPENIM_APISERVER_SECURE_TLS_CERT_KEY_CERT_FILE=${OPENIM_APISERVER_SECURE_TLS_CERT_KEY_CERT_FILE:-${OPENIM_CONFIG_DIR}/cert/openim-apiserver.pem}
readonly OPENIM_APISERVER_SECURE_TLS_CERT_KEY_PRIVATE_KEY_FILE=${OPENIM_APISERVER_SECURE_TLS_CERT_KEY_PRIVATE_KEY_FILE:-${OPENIM_CONFIG_DIR}/cert/openim-apiserver-key.pem}
# openim-authz-server 配置
readonly OPENIM_AUTHZ_SERVER_HOST=${OPENIM_AUTHZ_SERVER_HOST:-127.0.0.1} # openim-authz-server 部署机器 IP 地址
readonly OPENIM_AUTHZ_SERVER_INSECURE_BIND_ADDRESS=${OPENIM_AUTHZ_SERVER_INSECURE_BIND_ADDRESS:-127.0.0.1}
readonly OPENIM_AUTHZ_SERVER_INSECURE_BIND_PORT=${OPENIM_AUTHZ_SERVER_INSECURE_BIND_PORT:-9090}
readonly OPENIM_AUTHZ_SERVER_SECURE_BIND_ADDRESS=${OPENIM_AUTHZ_SERVER_SECURE_BIND_ADDRESS:-0.0.0.0}
readonly OPENIM_AUTHZ_SERVER_SECURE_BIND_PORT=${OPENIM_AUTHZ_SERVER_SECURE_BIND_PORT:-9443}
readonly OPENIM_AUTHZ_SERVER_SECURE_TLS_CERT_KEY_CERT_FILE=${OPENIM_AUTHZ_SERVER_SECURE_TLS_CERT_KEY_CERT_FILE:-${OPENIM_CONFIG_DIR}/cert/openim-authz-server.pem}
readonly OPENIM_AUTHZ_SERVER_SECURE_TLS_CERT_KEY_PRIVATE_KEY_FILE=${OPENIM_AUTHZ_SERVER_SECURE_TLS_CERT_KEY_PRIVATE_KEY_FILE:-${OPENIM_CONFIG_DIR}/cert/openim-authz-server-key.pem}
readonly OPENIM_AUTHZ_SERVER_CLIENT_CA_FILE=${OPENIM_AUTHZ_SERVER_CLIENT_CA_FILE:-${CA_FILE}}
readonly OPENIM_AUTHZ_SERVER_RPCSERVER=${OPENIM_AUTHZ_SERVER_RPCSERVER:-${OPENIM_APISERVER_HOST}:${OPENIM_APISERVER_GRPC_BIND_PORT}}
# openim-pump 配置
readonly OPENIM_PUMP_HOST=${OPENIM_PUMP_HOST:-127.0.0.1} # openim-pump 部署机器 IP 地址
readonly OPENIM_PUMP_COLLECTION_NAME=${OPENIM_PUMP_COLLECTION_NAME:-openim_analytics}
readonly OPENIM_PUMP_MONGO_URL=${OPENIM_PUMP_MONGO_URL:-mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/${OPENIM_PUMP_COLLECTION_NAME}?authSource=${OPENIM_PUMP_COLLECTION_NAME}}
# openim-watcher配置
readonly OPENIM_WATCHER_HOST=${OPENIM_WATCHER_HOST:-127.0.0.1} # openim-watcher 部署机器 IP 地址
def "OPENIM_DATA_DIR" "/data/openim"
def "OPENIM_INSTALL_DIR" "/opt/openim"
def "OPENIM_CONFIG_DIR" "/etc/openim"
def "OPENIM_LOG_DIR" "/var/log/openim"
def "CA_FILE" "${OPENIM_CONFIG_DIR}/cert/ca.pem"
# openim-api 配置
def "OPENIM_APISERVER_HOST" "127.0.0.1"
def "OPENIM_APISERVER_GRPC_BIND_ADDRESS" "0.0.0.0"
def "OPENIM_APISERVER_GRPC_BIND_PORT" "8081"
def "OPENIM_APISERVER_INSECURE_BIND_ADDRESS" "127.0.0.1"
def "OPENIM_APISERVER_INSECURE_BIND_PORT" "8080"
def "OPENIM_APISERVER_SECURE_BIND_ADDRESS" "0.0.0.0"
def "OPENIM_APISERVER_SECURE_BIND_PORT" "8443"
def "OPENIM_APISERVER_SECURE_TLS_CERT_KEY_CERT_FILE" "${OPENIM_CONFIG_DIR}/cert/openim-apiserver.pem"
def "OPENIM_APISERVER_SECURE_TLS_CERT_KEY_PRIVATE_KEY_FILE" "${OPENIM_CONFIG_DIR}/cert/openim-apiserver-key.pem"
# openimctl 配置
readonly CONFIG_USER_USERNAME=${CONFIG_USER_USERNAME:-admin}
readonly CONFIG_USER_PASSWORD=${CONFIG_USER_PASSWORD:-Admin@2021}
readonly CONFIG_USER_CLIENT_CERTIFICATE=${CONFIG_USER_CLIENT_CERTIFICATE:-${HOME}/.openim/cert/admin.pem}
readonly CONFIG_USER_CLIENT_KEY=${CONFIG_USER_CLIENT_KEY:-${HOME}/.openim/cert/admin-key.pem}
readonly CONFIG_SERVER_ADDRESS=${CONFIG_SERVER_ADDRESS:-${OPENIM_APISERVER_HOST}:${OPENIM_APISERVER_SECURE_BIND_PORT}}
readonly CONFIG_SERVER_CERTIFICATE_AUTHORITY=${CONFIG_SERVER_CERTIFICATE_AUTHORITY:-${CA_FILE}}
def "CONFIG_USER_USERNAME" "admin"
def "CONFIG_USER_PASSWORD" "Admin@2021"
def "CONFIG_USER_CLIENT_CERTIFICATE" "${HOME}/.openim/cert/admin.pem"
def "CONFIG_USER_CLIENT_KEY" "${HOME}/.openim/cert/admin-key.pem"
def "CONFIG_SERVER_ADDRESS" "${OPENIM_APISERVER_HOST}:${OPENIM_APISERVER_SECURE_BIND_PORT}"
def "CONFIG_SERVER_CERTIFICATE_AUTHORITY" "${CA_FILE}"

@ -1,3 +1,4 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -13,24 +14,6 @@
# limitations under the License.
object:
enable: "${OBJECT_ENABLE}"
apiURL: "${OBJECT_APIURL}"
minio:
bucket: "${MINIO_BUCKET}"
endpoint: "${MINIO_ENDPOINT}"
accessKeyID: "${MINIO_ACCESS_KEY}"
secretAccessKey: "${MINIO_SECRET_KEY}"
sessionToken: ""
cos:
bucketURL: "${COS_BUCKET_URL}"
secretID: ""
secretKey: ""
sessionToken: ""
oss:
endpoint: "${OSS_ENDPOINT}"
bucket: "${OSS_BUCKET}"
bucketURL: "${OSS_BUCKET_URL}"
accessKeyID: "${OSS_ACCESS_KEY_ID}"
accessKeySecret: ""
sessionToken: ""
# The root of the build/dist directory
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
source "${OPENIM_ROOT}/scripts/install/common.sh"

@ -0,0 +1,89 @@
#!/usr/bin/env bash
# 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.
# The root of the build/dist directory
IAM_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
[[ -z ${COMMON_SOURCED} ]] && source ${IAM_ROOT}/scripts/install/common.sh
# Print the necessary information after installation
function openim::redis::info() {
cat << EOF
Redis Login: redis-cli --no-auth-warning -h ${REDIS_HOST} -p ${REDIS_PORT} -a '${REDIS_PASSWORD}'
EOF
}
# 安装
function openim::redis::install()
{
# 1. 安装 Redis
openim::common::sudo "apt-get -y install redis-server"
# 2. 配置 Redis
# 2.1 修改 `/etc/redis/redis.conf` 文件,将 daemonize 由 no 改成 yes表示允许 Redis 在后台启动
echo ${LINUX_PASSWORD} | sudo -S sed -i '/^daemonize/{s/no/yes/}' /etc/redis/redis.conf
# 2.2 在 `bind 127.0.0.1` 前面添加 `#` 将其注释掉,默认情况下只允许本地连接,注释掉后外网可以连接 Redis
echo ${LINUX_PASSWORD} | sudo -S sed -i '/^# bind 127.0.0.1/{s/# //}' /etc/redis/redis.conf
# 2.3 修改 requirepass 配置,设置 Redis 密码
echo ${LINUX_PASSWORD} | sudo -S sed -i 's/^# requirepass.*$/requirepass '"${REDIS_PASSWORD}"'/' /etc/redis/redis.conf
# 2.4 因为我们上面配置了密码登录,需要将 protected-mode 设置为 no关闭保护模式
echo ${LINUX_PASSWORD} | sudo -S sed -i '/^protected-mode/{s/yes/no/}' /etc/redis/redis.conf
# 3. 为了能够远程连上 Redis需要执行以下命令关闭防火墙并禁止防火墙开机启动如果不需要远程连接可忽略此步骤
openim::common::sudo "sudo ufw disable"
openim::common::sudo "sudo ufw status"
# 4. 启动 Redis
openim::common::sudo "redis-server /etc/redis/redis.conf"
openim::redis::status || return 1
openim::redis::info
openim::log::info "install Redis successfully"
}
# 卸载
function openim::redis::uninstall()
{
set +o errexit
openim::common::sudo "/etc/init.d/redis-server stop"
openim::common::sudo "apt-get -y remove redis-server"
openim::common::sudo "rm -rf /var/lib/redis"
set -o errexit
openim::log::info "uninstall Redis successfully"
}
# 状态检查
function openim::redis::status()
{
if [[ -z "`pgrep redis-server`" ]];then
openim::log::error_exit "Redis not running, maybe not installed properly"
return 1
fi
redis-cli --no-auth-warning -h ${REDIS_HOST} -p ${REDIS_PORT} -a "${REDIS_PASSWORD}" --hotkeys || {
openim::log::error "can not login with ${REDIS_USERNAME}, redis maybe not initialized properly"
return 1
}
openim::log::info "redis-server status active"
}
#eval $*
if [[ "$*" =~ openim::redis:: ]];then
eval $*
fi

@ -22,15 +22,6 @@ OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
source $SCRIPTS_ROOT/lib/init.sh
source $SCRIPTS_ROOT/path_info.sh
cd $SCRIPTS_ROOT
echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
#service filename
service_filename=(
#api
@ -106,7 +97,6 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
if [ $i -eq 0 -o $i -eq 1 ]; then
cmd="./${service_filename[$i]} --port ${service_ports[$j]}"
fi
echo $cmd
echo "=====================start ${service_filename[$i]}======================">>$OPENIM_ROOT/logs/openIM.log
nohup $cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
sleep 1

@ -896,6 +896,13 @@ function openim::util::run::relative() {
done
}
function openim::util::onCtrlC () {
#Capture CTRL+C, terminate the background process of the program when the script is terminated in the form of ctrl+c
kill -9 ${do_sth_pid} ${progress_pid}
echo
echo '!!! openim: Ctrl+C is captured'
exit 1
}
# input: [10023, 2323, 3434]
# output: 10023 2323 3434

@ -0,0 +1,384 @@
# 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.
# -----------------------------------------------------------------
# This config file is the template file
# -| source: scripts/template/config-tmpl/openim_config.yaml
# -| env: scripts/install/environment.sh
# -| target: config/config.yaml
# -----------------------------------------------------------------
###################### Zookeeper ######################
# Zookeeper configuration
# It's not recommended to modify the schema
#
# Zookeeper address
# Zookeeper username
# Zookeeper password
zookeeper:
schema: "${ZOOKEEPER_SCHEMA}"
address: [ "${ZOOKEEPER_ADDRESS}" ]
username: "${ZOOKEEPER_USERNAME}"
password: "${ZOOKEEPER_PASSWORD}"
###################### Mysql ######################
# MySQL configuration
# Currently, only single machine setup is supported
#
# Maximum number of open connections
# Maximum number of idle connections
# Maximum lifetime in seconds a connection can be reused
# Log level: 1=slient, 2=error, 3=warn, 4=info
# Slow query threshold in milliseconds
mysql:
address: [ "${MYSQL_ADDRESS}" ]
username: "${MYSQL_USERNAME}"
password: "${MYSQL_PASSWORD}"
database: "${MYSQL_DATABASE}"
maxOpenConn: "${MYSQL_MAX_OPEN_CONN}"
maxIdleConn: "${MYSQL_MAX_IDLE_CONN}"
maxLifeTime: "${MYSQL_MAX_LIFETIME}"
logLevel: "${MYSQL_LOG_LEVEL}"
slowThreshold: "${MYSQL_SLOW_THRESHOLD}"
###################### Mongo ######################
# MongoDB configuration
# If uri is not empty, it will be used directly
#
# MongoDB address for standalone setup, Mongos address for sharded cluster setup
# Default MongoDB database name
# Maximum connection pool size
mongo:
uri: "${MONGO_URI}"
address: [ "${MONGO_ADDRESS}" ]
database: "${MONGO_DATABASE}"
username: "${MONGO_USERNAME}"
password: "${MONGO_PASSWORD}"
maxPoolSize: "${MONGO_MAX_POOL_SIZE}"
###################### Redis configuration information ######################
# Redis configuration
#
# Username is required only for Redis version 6.0+
redis:
address: [ "${REDIS_ADDRESS}" ]
username: "${REDIS_USERNAME}"
password: "${REDIS_PASSWORD}"
###################### Kafka configuration information ######################
# Kafka configuration
#
# Kafka username
# Kafka password
# It's not recommended to modify this topic name
# Consumer group ID, it's not recommended to modify
kafka:
username: "${KAFKA_USERNAME}"
password: "${KAFKA_PASSWORD}"
addr: [ "${KAFKA_ADDR}" ]
latestMsgToRedis:
topic: "${KAFKA_LATESTMSG_REDIS_TOPIC}"
offlineMsgToMongo:
topic: "${KAFKA_OFFLINEMSG_MONGO_TOPIC}"
msgToPush:
topic: "${KAFKA_MSG_PUSH_TOPIC}"
consumerGroupID:
msgToRedis: "${KAFKA_CONSUMERGROUPID_REDIS}"
msgToMongo: "${KAFKA_CONSUMERGROUPID_MONGO}"
msgToMySql: "${KAFKA_CONSUMERGROUPID_MYSQL}"
msgToPush: "${KAFKA_CONSUMERGROUPID_PUSH}"
###################### RPC configuration information ######################
# RPC configuration
#
# IP address to register with zookeeper when starting RPC, the IP and corresponding rpcPort should be accessible by api/gateway
# Default listen IP is 0.0.0.0
rpc:
registerIP: "${RPC_REGISTER_IP}"
listenIP: "${RPC_LISTEN_IP}"
###################### API configuration information ######################
# API configuration
#
# API service port
# Default listen IP is 0.0.0.0
api:
openImApiPort: [ "${API_OPENIM_PORT}" ]
listenIP: "${API_LISTEN_IP}"
###################### Object configuration information ######################
# Object storage configuration
#
# Use minio for object storage
# API URL should be accessible by the app
# It's not recommended to modify the bucket name
# Endpoint should be accessible by the app
# Session token
# Configuration for Tencent COS
# Configuration for Aliyun OSS
# It can be set by an environment variable or by a script
object:
enable: "${OBJECT_ENABLE}"
apiURL: "${OBJECT_APIURL}"
minio:
bucket: "${MINIO_BUCKET}"
endpoint: "${MINIO_ENDPOINT}"
accessKeyID: "${MINIO_ACCESS_KEY}"
secretAccessKey: "${MINIO_SECRET_KEY}"
sessionToken: "${MINIO_SESSION_TOKEN}"
cos:
bucketURL: "${COS_BUCKET_URL}"
secretID: "${COS_SECRET_ID}"
secretKey: "${COS_SECRET_KEY}"
sessionToken: "${COS_SESSION_TOKEN}"
oss:
endpoint: "${OSS_ENDPOINT}"
bucket: "${OSS_BUCKET}"
bucketURL: "${OSS_BUCKET_URL}"
accessKeyID: "${OSS_ACCESS_KEY_ID}"
accessKeySecret: "${OSS_ACCESS_KEY_SECRET}"
sessionToken: "${OSS_SESSION_TOKEN}"
###################### RPC Port Configuration ######################
# RPC service ports
# These ports are passed into the program by the script and are not recommended to modify
# For launching multiple programs, just fill in multiple ports separated by commas
# For example, [10110, 10111]
rpcPort:
openImUserPort: [ "${OPENIM_USER_PORT}" ]
openImFriendPort: [ "${OPENIM_FRIEND_PORT}" ]
openImMessagePort: [ "${OPENIM_MESSAGE_PORT}" ]
openImMessageGatewayPort: [ "${OPENIM_MESSAGE_GATEWAY_PORT}" ]
openImGroupPort: [ "${OPENIM_GROUP_PORT}" ]
openImAuthPort: [ "${OPENIM_AUTH_PORT}" ]
openImPushPort: [ "${OPENIM_PUSH_PORT}" ]
openImConversationPort: [ "${OPENIM_CONVERSATION_PORT}" ]
openImThirdPort: [ "${OPENIM_THIRD_PORT}" ]
###################### RPC Register Name Configuration ######################
# RPC service names for registration, it's not recommended to modify these
rpcRegisterName:
openImUserName: "${OPENIM_USER_NAME}"
openImFriendName: "${OPENIM_FRIEND_NAME}"
openImMsgName: "${OPENIM_MSG_NAME}"
openImPushName: "${OPENIM_PUSH_NAME}"
openImMessageGatewayName: "${OPENIM_MESSAGE_GATEWAY_NAME}"
openImGroupName: "${OPENIM_GROUP_NAME}"
openImAuthName: "${OPENIM_AUTH_NAME}"
openImConversationName: "${OPENIM_CONVERSATION_NAME}"
openImThirdName: "${OPENIM_THIRD_NAME}"
###################### Log Configuration ######################
# Log configuration
#
# Storage directory
# Log rotation time
# Maximum number of logs to retain
# Log level, 6 means all levels
# Whether to output to stdout
# Whether to output in json format
# Whether to include stack trace in logs
log:
storageLocation: "${LOG_STORAGE_LOCATION}"
rotationTime: ${LOG_ROTATION_TIME}
remainRotationCount: ${LOG_REMAIN_ROTATION_COUNT}
remainLogLevel: ${LOG_REMAIN_LOG_LEVEL}
isStdout: ${LOG_IS_STDOUT}
isJson: ${LOG_IS_JSON}
withStack: ${LOG_WITH_STACK}
###################### Variables definition ######################
# Long connection server configuration
#
# Websocket port for msg_gateway
# Maximum number of websocket connections
# Maximum length of websocket request package
# Websocket connection handshake timeout
longConnSvr:
openImWsPort: [ "${OPENIM_WS_PORT}" ]
websocketMaxConnNum: ${WEBSOCKET_MAX_CONN_NUM}
websocketMaxMsgLen: ${WEBSOCKET_MAX_MSG_LEN}
websocketTimeout: ${WEBSOCKET_TIMEOUT}
# Push notification service configuration
#
# Use GeTui for push notifications
# GeTui offline push configuration
# FCM offline push configuration
# Account file, place it in the config directory
# JPush configuration, modify these after applying in JPush backend
push:
enable: "${PUSH_ENABLE}"
geTui:
pushUrl: "${GETUI_PUSH_URL}"
masterSecret: ""
appKey: ""
intent: ""
channelID: ""
channelName: ""
fcm:
serviceAccount: "${FCM_SERVICE_ACCOUNT}"
jpns:
appKey: "${JPNS_APP_KEY}"
masterSecret: "${JPNS_MASTER_SECRET}"
pushUrl: "${JPNS_PUSH_URL}"
pushIntent: "${JPNS_PUSH_INTENT}"
# App manager configuration
#
# Built-in app manager user IDs
# Built-in app manager nicknames
manager:
userID: [ "${MANAGER_USERID_1}", "${MANAGER_USERID_2}", "${MANAGER_USERID_3}" ]
nickname: [ "${NICKNAME_1}", "${NICKNAME_2}", "${NICKNAME_3}" ]
# Multi-platform login policy
# For each platform(Android, iOS, Windows, Mac, web), only one can be online at a time
multiLoginPolicy: ${MULTILOGIN_POLICY}
# Whether to store messages in MySQL, messages in MySQL are only used for management background
chatPersistenceMysql: ${CHAT_PERSISTENCE_MYSQL}
# Message cache timeout in seconds, it's not recommended to modify
msgCacheTimeout: ${MSG_CACHE_TIMEOUT}
# Whether to enable read receipts for group chat
groupMessageHasReadReceiptEnable: ${GROUP_MSG_READ_RECEIPT}
# Whether to enable read receipts for single chat
singleMessageHasReadReceiptEnable: ${SINGLE_MSG_READ_RECEIPT}
# MongoDB offline message retention period in days
retainChatRecords: ${RETAIN_CHAT_RECORDS}
# Schedule to clear expired messages(older than retainChatRecords days) in MongoDB every Wednesday at 2am
# This deletion is just for cleaning up disk usage according to previous configuration retainChatRecords, no notification will be sent
chatRecordsClearTime: "${CHAT_RECORDS_CLEAR_TIME}"
# Schedule to auto delete messages every day at 2am
# This deletion is for messages that have been retained for more than msg_destruct_time (seconds) in the conversation field
msgDestructTime: "${MSG_DESTRUCT_TIME}"
# Secret key
secret: "${SECRET}"
# Token policy
#
# Token expiration period in days
tokenPolicy:
expire: ${TOKEN_EXPIRE}
# Message verification policy
#
# Whether to verify friendship when sending messages
messageVerify:
friendVerify: false
# iOS push notification configuration
#
# iOS push notification sound
# Whether to count badge
# Whether it's production environment
iosPush:
pushSound: "xxx"
badgeCount: true
production: false
###################### Third-party service configuration ######################
# Callback configuration
#
# Callback URL
# Whether to enable this callback event
# Timeout in seconds
# Whether to continue execution if callback fails
callback:
url:
beforeSendSingleMsg:
enable: false
timeout: 5
failedContinue: true
afterSendSingleMsg:
enable: false
timeout: 5
beforeSendGroupMsg:
enable: false
timeout: 5
failedContinue: true
afterSendGroupMsg:
enable: false
timeout: 5
msgModify:
enable: false
timeout: 5
failedContinue: true
userOnline:
enable: false
timeout: 5
userOffline:
enable: false
timeout: 5
userKickOff:
enable: false
timeout: 5
offlinePush:
enable: false
timeout: 5
failedContinue: true
onlinePush:
enable: false
timeout: 5
failedContinue: true
superGroupOnlinePush:
enable: false
timeout: 5
failedContinue: true
beforeAddFriend:
enable: false
timeout: 5
failedContinue: true
beforeCreateGroup:
enable: false
timeout: 5
failedContinue: true
beforeMemberJoinGroup:
enable: false
timeout: 5
failedContinue: true
beforeSetGroupMemberInfo:
enable: false
timeout: 5
failedContinue: true
setMessageReactionExtensions:
enable: false
timeout: 5
failedContinue: true
###################### Prometheus ######################
# Prometheus configuration for various services
# The number of Prometheus ports per service needs to correspond to rpcPort
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
prometheus:
enable: "${PROMETHEUS_ENABLE}"
userPrometheusPort: [ "${USER_PROM_PORT}" ]
friendPrometheusPort: [ "${FRIEND_PROM_PORT}" ]
messagePrometheusPort: [ "${MESSAGE_PROM_PORT}" ]
messageGatewayPrometheusPort: [ "${MSG_GATEWAY_PROM_PORT}" ]
groupPrometheusPort: [ "${GROUP_PROM_PORT}" ]
authPrometheusPort: [ "${AUTH_PROM_PORT}" ]
pushPrometheusPort: [ "${PUSH_PROM_PORT}" ]
conversationPrometheusPort: [ "${CONVERSATION_PROM_PORT}" ]
rtcPrometheusPort: [ "${RTC_PROM_PORT}" ]
thirdPrometheusPort: [ "${THIRD_PROM_PORT}" ]
messageTransferPrometheusPort: [ "${MSG_TRANSFER_PROM_PORTS}" ] # List of ports
Loading…
Cancel
Save