feat: add env config options

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong(cubxxw-openim)
2023-08-16 10:29:08 +08:00
parent c534b84dd2
commit d111769a93
3 changed files with 131 additions and 125 deletions
+8 -13
View File
@@ -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"
+23 -12
View File
@@ -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用户服务名称