feat: add env config options

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

@ -1,6 +1,6 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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
#
@ -13,7 +13,7 @@
# limitations under the License.
# -----------------------------------------------------------------
# This config file is the template file
# TODO: This config file is the template file
# --| source: scripts/template/config-tmpl/openim_config.yaml
# --| env: scripts/install/environment.sh
# --| target: config/config.yaml
@ -27,10 +27,10 @@
# Zookeeper username
# Zookeeper password
zookeeper:
schema: "${ZOOKEEPER_SCHEMA}"
address: [ "${ZOOKEEPER_ADDRESS}" ]
username: "${ZOOKEEPER_USERNAME}"
password: "${ZOOKEEPER_PASSWORD}"
schema: ${ZOOKEEPER_SCHEMA}
address: [ ${ZOOKEEPER_ADDRESS} ]
username: ${ZOOKEEPER_USERNAME}
password: ${ZOOKEEPER_PASSWORD}
###################### Mysql ######################
# MySQL configuration
@ -42,15 +42,15 @@ zookeeper:
# 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}"
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
@ -60,21 +60,21 @@ mysql:
# 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}"
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}"
address: [ ${REDIS_ADDRESS} ]
username: ${REDIS_USERNAME}
password: ${REDIS_PASSWORD}
###################### Kafka configuration information ######################
# Kafka configuration
@ -84,20 +84,20 @@ redis:
# 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}" ]
username: ${KAFKA_USERNAME}
password: ${KAFKA_PASSWORD}
addr: [ ${KAFKA_ADDR} ]
latestMsgToRedis:
topic: "${KAFKA_LATESTMSG_REDIS_TOPIC}"
topic: ${KAFKA_LATESTMSG_REDIS_TOPIC}
offlineMsgToMongo:
topic: "${KAFKA_OFFLINEMSG_MONGO_TOPIC}"
topic: ${KAFKA_OFFLINEMSG_MONGO_TOPIC}
msgToPush:
topic: "${KAFKA_MSG_PUSH_TOPIC}"
topic: ${KAFKA_MSG_PUSH_TOPIC}
consumerGroupID:
msgToRedis: "${KAFKA_CONSUMERGROUPID_REDIS}"
msgToMongo: "${KAFKA_CONSUMERGROUPID_MONGO}"
msgToMySql: "${KAFKA_CONSUMERGROUPID_MYSQL}"
msgToPush: "${KAFKA_CONSUMERGROUPID_PUSH}"
msgToRedis: ${KAFKA_CONSUMERGROUPID_REDIS}
msgToMongo: ${KAFKA_CONSUMERGROUPID_MONGO}
msgToMySql: ${KAFKA_CONSUMERGROUPID_MYSQL}
msgToPush: ${KAFKA_CONSUMERGROUPID_PUSH}
###################### RPC configuration information ######################
# RPC configuration
@ -105,8 +105,8 @@ kafka:
# 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}"
registerIP: ${RPC_REGISTER_IP}
listenIP: ${RPC_LISTEN_IP}
###################### API configuration information ######################
# API configuration
@ -114,8 +114,8 @@ rpc:
# API service port
# Default listen IP is 0.0.0.0
api:
openImApiPort: [ "${API_OPENIM_PORT}" ]
listenIP: "${API_LISTEN_IP}"
openImApiPort: [ ${API_OPENIM_PORT} ]
listenIP: ${API_LISTEN_IP}
###################### Object configuration information ######################
# Object storage configuration
@ -129,26 +129,26 @@ api:
# Configuration for Aliyun OSS
# It can be set by an environment variable or by a script
object:
enable: "${OBJECT_ENABLE}"
apiURL: "${OBJECT_APIURL}"
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}"
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}"
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}"
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 ######################
@ -157,28 +157,28 @@ object:
# 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}" ]
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}"
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
@ -207,7 +207,7 @@ log:
# Maximum length of websocket request package
# Websocket connection handshake timeout
longConnSvr:
openImWsPort: [ "${OPENIM_WS_PORT}" ]
openImWsPort: [ ${OPENIM_WS_PORT} ]
websocketMaxConnNum: ${WEBSOCKET_MAX_CONN_NUM}
websocketMaxMsgLen: ${WEBSOCKET_MAX_MSG_LEN}
websocketTimeout: ${WEBSOCKET_TIMEOUT}
@ -220,21 +220,21 @@ longConnSvr:
# Account file, place it in the config directory
# JPush configuration, modify these after applying in JPush backend
push:
enable: "${PUSH_ENABLE}"
enable: ${PUSH_ENABLE}
geTui:
pushUrl: "${GETUI_PUSH_URL}"
masterSecret: ""
appKey: ""
intent: ""
channelID: ""
channelName: ""
masterSecret:
appKey:
intent:
channelID:
channelName:
fcm:
serviceAccount: "${FCM_SERVICE_ACCOUNT}"
serviceAccount: ${FCM_SERVICE_ACCOUNT}
jpns:
appKey: "${JPNS_APP_KEY}"
masterSecret: "${JPNS_MASTER_SECRET}"
pushUrl: "${JPNS_PUSH_URL}"
pushIntent: "${JPNS_PUSH_INTENT}"
appKey: ${JPNS_APP_KEY}
masterSecret: ${JPNS_MASTER_SECRET}
pushUrl: ${JPNS_PUSH_URL}
pushIntent: ${JPNS_PUSH_INTENT}
# App manager configuration
#
@ -242,7 +242,7 @@ push:
# Built-in app manager nicknames
manager:
userID: [ "${MANAGER_USERID_1}", "${MANAGER_USERID_2}", "${MANAGER_USERID_3}" ]
nickname: [ "${NICKNAME_1}", "${NICKNAME_2}", "${NICKNAME_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
@ -272,7 +272,7 @@ chatRecordsClearTime: "${CHAT_RECORDS_CLEAR_TIME}"
msgDestructTime: "${MSG_DESTRUCT_TIME}"
# Secret key
secret: "${SECRET}"
secret: ${SECRET}
# Token policy
#
@ -370,15 +370,15 @@ callback:
# 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
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

@ -17,15 +17,16 @@
# 示例:./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"
# Path to the generated config file
template_file="$2"
. $(dirname ${BASH_SOURCE})/lib/init.sh
IAM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${IAM_ROOT}/scripts/lib/init.sh"
if [ $# -ne 2 ];then
openim::log::error_exit "Usage: genconfig.sh scripts/environment.sh configs/openim-api.yaml"
iam::log::error "Usage: genconfig.sh scripts/environment.sh configs/iam-apiserver.yaml"
exit 1
fi
source "${env_file}"
@ -36,22 +37,16 @@ set +u
for env in $(sed -n 's/^[^#].*${\(.*\)}.*/\1/p' ${template_file})
do
if [ -z "$(eval echo \$${env})" ];then
openim::log::error "environment variable '${env}' not set"
iam::log::error "environment variable '${env}' not set"
missing=true
fi
done
if [ "${missing}" ];then
openim::log::error 'You may run `source scripts/environment.sh` to set these environment'
iam::log::error 'You may run `source scripts/environment.sh` to set these environment'
exit 1
fi
temp_output=$(mktemp) # 创建一个临时文件存储原始输出
eval "cat << EOF
$(cat ${template_file})
EOF" > $temp_output
sed "s/''//g" $temp_output
rm $temp_output
EOF"

@ -70,8 +70,8 @@ def "CA_FILE" "${OPENIM_CONFIG_DIR}/cert/ca.pem"
###################### Zookeeper 配置信息 ######################
def "ZOOKEEPER_SCHEMA" "openim" # Zookeeper的模式
def "ZOOKEEPER_ADDRESS" "127.0.0.1:2181" # Zookeeper的地址
def "ZOOKEEPER_USERNAME" # Zookeeper的用户名
def "ZOOKEEPER_PASSWORD" # Zookeeper的密码
def "ZOOKEEPER_USERNAME" "" # Zookeeper的用户名
def "ZOOKEEPER_PASSWORD" "" # Zookeeper的密码
###################### MySQL 配置信息 ######################
def "MYSQL_ADDRESS" "127.0.0.1:13306" # MySQL的地址
@ -138,16 +138,27 @@ def "API_LISTEN_IP" "0.0.0.0" # API的监听IP
###################### RPC Port Configuration Variables ######################
# For launching multiple programs, just fill in multiple ports separated by commas
# For example, [10110, 10111]
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第三方服务端口
# For example:
# readonly OPENIM_USER_PORT=${OPENIM_USER_PORT:-'10110, 10111, 10112'}
# OpenIM用户服务端口
readonly OPENIM_USER_PORT=${OPENIM_USER_PORT:-'10110'}
# OpenIM朋友服务端口
readonly OPENIM_FRIEND_PORT=${OPENIM_FRIEND_PORT:-'10120'}
# OpenIM消息服务端口
readonly OPENIM_MESSAGE_PORT=${OPENIM_MESSAGE_PORT:-'10130'}
# OpenIM消息网关服务端口
readonly OPENIM_MESSAGE_GATEWAY_PORT=${OPENIM_MESSAGE_GATEWAY_PORT:-'10140'}
# OpenIM组服务端口
readonly OPENIM_GROUP_PORT=${OPENIM_GROUP_PORT:-'10150'}
# OpenIM授权服务端口
readonly OPENIM_AUTH_PORT=${OPENIM_AUTH_PORT:-'10160'}
# OpenIM推送服务端口
readonly OPENIM_PUSH_PORT=${OPENIM_PUSH_PORT:-'10170'}
# OpenIM对话服务端口
readonly OPENIM_CONVERSATION_PORT=${OPENIM_CONVERSATION_PORT:-'10180'}
# OpenIM第三方服务端口
readonly OPENIM_THIRD_PORT=${OPENIM_THIRD_PORT:-'10190'}
###################### RPC Register Name Variables ######################
def "OPENIM_USER_NAME" "User" # OpenIM用户服务名称

Loading…
Cancel
Save