feat: add start sctips help

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

@ -23,60 +23,10 @@ set -o nounset
set -o pipefail
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh"
source "${OPENIM_ROOT}/scripts/path_info.sh"
source "${OPENIM_ROOT}/scripts/install/common.sh"
OPENIM_VERBOSE=4
service_port_name=(
openImWsPort
openImApiPort
openImUserPort
openImFriendPort
openImMessagePort
openImMessageGatewayPort
openImGroupPort
openImAuthPort
openImPushPort
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
for j in ${ports_array}; do
port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
if [[ ${port} -ne ${j} ]]; then
openim::log::info "service does not start normally,not initiated port is "${COLOR_SUFFIX}${BACKGROUND_GREEN}${j}
echo "please check ${log_file}"
exit -1
else
echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX}
fi
done
done
#Check launched service process
check=$(ps aux | grep -w ./${openim_msgtransfer} | grep -v grep | wc -l)
if [ $check -eq ${msg_transfer_service_num} ]; then
echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTransfer"${COLOR_SUFFIX}
else
echo $check ${msg_transfer_service_num}
echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX}
echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX}
exit -1
fi
check=$(ps aux | grep -w ./${cron_task_name} | grep -v grep | wc -l)
if [ $check -ge 1 ]; then
echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImCronTask"${COLOR_SUFFIX}
else
echo -e ${RED_PREFIX}"cron_task_name service does not start normally"${COLOR_SUFFIX}
echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX}
exit -1
fi
echo "The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}"
echo -e ${BACKGROUND_GREEN}"all services launch success"${COLOR_SUFFIX}
openim::util::check_ports ${OPENIM_SERVER_PORT_LISTARIES[@]}

@ -30,10 +30,29 @@ source "${OPENIM_ROOT}/scripts/lib/init.sh"
# Make sure the environment is only called via common to avoid too much nesting
source "${OPENIM_ROOT}/scripts/install/environment.sh"
service_port_name={
# Storing all the defined ports in an array for easy management and access.
# This array consolidates the port numbers for all the services defined above.
openim::common::service_port_name() {
local targets=(
$OPENIM_USER_PORT # User service
$OPENIM_FRIEND_PORT # Friend service
$OPENIM_MESSAGE_PORT # Message service
$OPENIM_MESSAGE_GATEWAY_PORT # Message gateway
$OPENIM_GROUP_PORT # Group service
$OPENIM_AUTH_PORT # Authorization service
$OPENIM_PUSH_PORT # Push service
$OPENIM_CONVERSATION_PORT # Conversation service
$OPENIM_THIRD_PORT # Third-party service
$API_OPENIM_PORT # API service
$OPENIM_WS_PORT # WebSocket service
)
echo "${targets[@]}"
}
IFS=" " read -ra OPENIM_SERVER_PORT_TARGETS <<< "$(openim::common::service_port_name)"
readonly OPENIM_SERVER_PORT_TARGETS
readonly OPENIM_SERVER_PORT_LISTARIES=("${OPENIM_SERVER_PORT_TARGETS[@]##*/}")
# Execute commands that require root permission without entering a password
function openim::common::sudo {
echo ${LINUX_PASSWORD} | sudo -S $1

@ -15,8 +15,11 @@
# This script will install the dependencies required for openim
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
set -o errexit
set +o nounset
set -o pipefail
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
# Start MySQL service

@ -16,6 +16,7 @@
# 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
# 格式化 bash 注释https://tool.lu/shell/
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
@ -26,9 +27,9 @@ source "${OPENIM_ROOT}/scripts/lib/util.sh"
IP=$(openim::util::get_server_ip)
function def() {
local var_name="$1"
local default_value="${2:-}"
eval "readonly $var_name=\"\${$var_name:-$(printf '%q' "$default_value")}\""
local var_name="$1"
local default_value="${2:-}"
eval "readonly $var_name=\"\${$var_name:-$(printf '%q' "$default_value")}\""
}
# app要能访问到此ip和端口或域名
@ -59,158 +60,219 @@ def "ENV_FILE" "${OPENIM_ROOT}/scripts/install/environment.sh"
# TODO 使用 readonly 来定义合适,负责无法正常解析
###################### 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_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" "${USER}" # MySQL的用户名
def "MYSQL_PASSWORD" "${PASSWORD}" # MySQL的密码
def "MYSQL_DATABASE" "${DATABASE_NAME}" # 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" # 慢查询阈值(毫秒)
def "MYSQL_ADDRESS" "127.0.0.1:13306" # MySQL的地址
def "MYSQL_USERNAME" "${USER}" # MySQL的用户名
def "MYSQL_PASSWORD" "${PASSWORD}" # MySQL的密码
def "MYSQL_DATABASE" "${DATABASE_NAME}" # 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" "${DATABASE_NAME}" # MongoDB的数据库名
def "MONGO_USERNAME" "${USER}" # MongoDB的用户名
def "MONGO_PASSWORD" "${PASSWORD}" # MongoDB的密码
def "MONGO_MAX_POOL_SIZE" "100" # 最大连接池大小
def "MONGO_URI" # MongoDB的URI
def "MONGO_ADDRESS" "127.0.0.1:37017" # MongoDB的地址
def "MONGO_DATABASE" "${DATABASE_NAME}" # MongoDB的数据库名
def "MONGO_USERNAME" "${USER}" # MongoDB的用户名
def "MONGO_PASSWORD" "${PASSWORD}" # 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://${IP}:10005" # MinIO的端点URL
def "MINIO_ACCESS_KEY" "${USER}" # MinIO的访问密钥ID
def "MINIO_SECRET_KEY" "${PASSWORD}" # MinIO的密钥
def "MINIO_SESSION_TOKEN" # MinIO的会话令牌
def "OBJECT_ENABLE" "minio" # 对象是否启用
def "OBJECT_APIURL" "http://127.0.0.1:10002/object/" # 对象的API地址
def "MINIO_BUCKET" "openim" # MinIO的存储桶名称
def "MINIO_ENDPOINT" "http://${IP}:10005" # MinIO的端点URL
def "MINIO_ACCESS_KEY" "${USER}" # MinIO的访问密钥ID
def "MINIO_SECRET_KEY" "${PASSWORD}" # 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" "${USER}" # 阿里云OSS的访问密钥ID
def "OSS_ACCESS_KEY_SECRET" # 阿里云OSS的密钥
def "OSS_SESSION_TOKEN" # 阿里云OSS的会话令牌
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" "${USER}" # 阿里云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" "${PASSWORD}" # Redis的密码
def "REDIS_ADDRESS" "127.0.0.1:16379" # Redis的地址
def "REDIS_USERNAME" # Redis的用户名
def "REDIS_PASSWORD" "${PASSWORD}" # 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到推送
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
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
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第三方服务端口
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_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第三方服务名称
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" "${OPENIM_ROOT}/log/" # 日志存储位置
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" # 日志是否带有堆栈信息
def "LOG_STORAGE_LOCATION" "${OPENIM_ROOT}/log/" # 日志存储位置
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 "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" # 推送是否启用
# GeTui推送URL
readonly GETUI_PUSH_URL=${GETUI_PUSH_URL:-'https://restapi.getui.com/v2/$appId'}
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 "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" # 保留聊天记录
# 聊天记录清理时间
readonly CHAT_RECORDS_CLEAR_TIME=${CHAT_RECORDS_CLEAR_TIME:-'0 2 * * *'}
# 消息销毁时间
readonly MSG_DESTRUCT_TIME=${MSG_DESTRUCT_TIME:-'0 2 * * *'}
def "SECRET" "${PASSWORD}" # 密钥
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生产
def "SECRET" "${PASSWORD}" # 密钥
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 "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 端口
# Message Transfer 服务的 Prometheus 端口列表
readonly MSG_TRANSFER_PROM_PORTS=${MSG_TRANSFER_PROM_PORTS:-'21400, 21401, 21402, 21403'}
###################### OpenIM openim-api ######################
def "OPENIM_API_BINARY" "${LOCAL_OUTPUT_ROOT}/bin/platforms/linux/amd64/openim-api" # OpenIM openim-api 二进制文件路径
def "OPENIM_API_CONFIG" "${LOCAL_OUTPUT_ROOT}/bin/openim_config.yaml" # OpenIM openim-api 配置文件路径
def "OPENIM_API_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-api" # OpenIM openim-api 日志存储路径
def "OPENIM_API_LOG_LEVEL" "info" # OpenIM openim-api 日志级别
def "OPENIM_API_LOG_MAX_SIZE" "100" # OpenIM openim-api 日志最大大小MB
def "OPENIM_API_LOG_MAX_BACKUPS" "7" # OpenIM openim-api 日志最大备份数
def "OPENIM_API_LOG_MAX_AGE" "7" # OpenIM openim-api 日志最大保存时间(天)
def "OPENIM_API_LOG_COMPRESS" "false" # OpenIM openim-api 日志是否压缩
def "OPENIM_API_LOG_WITH_STACK" "${LOG_WITH_STACK}" # OpenIM openim-api 日志是否带有堆栈信息
###################### OpenIM openim-cmdutils ######################
def "OPENIM_CMDUTILS_BINARY" "${LOCAL_OUTPUT_ROOT}/bin/platforms/linux/amd64/openim-cmdutils" # OpenIM openim-cmdutils 二进制文件路径
def "OPENIM_CMDUTILS_CONFIG" "${LOCAL_OUTPUT_ROOT}/bin/openim_config.yaml" # OpenIM openim-cmdutils 配置文件路径
def "OPENIM_CMDUTILS_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-cmdutils" # OpenIM openim-cmdutils 日志存储路径
def "OPENIM_CMDUTILS_LOG_LEVEL" "info" # OpenIM openim-cmdutils 日志级别
def "OPENIM_CMDUTILS_LOG_MAX_SIZE" "100" # OpenIM openim-cmdutils 日志最大大小MB
def "OPENIM_CMDUTILS_LOG_MAX_BACKUPS" "7" # OpenIM openim-cmdutils 日志最大备份数
def "OPENIM_CMDUTILS_LOG_MAX_AGE" "7" # OpenIM openim-cmdutils 日志最大保存时间(天)
def "OPENIM_CMDUTILS_LOG_COMPRESS" "false" # OpenIM openim-cmdutils 日志是否压缩
def "OPENIM_CMDUTILS_LOG_WITH_STACK" "${LOG_WITH_STACK}" # OpenIM openim-cmdutils 日志是否带有堆栈信息
###################### OpenIM openim-crontask ######################
def "OPENIM_CRONTASK_BINARY" "${LOCAL_OUTPUT_ROOT}/bin/platforms/linux/amd64/openim-crontask" # OpenIM openim-crontask 二进制文件路径
def "OPENIM_CRONTASK_CONFIG" "${LOCAL_OUTPUT_ROOT}/bin/openim_config.yaml" # OpenIM openim-crontask 配置文件路径
def "OPENIM_CRONTASK_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-crontask" # OpenIM openim-crontask 日志存储路径
def "OPENIM_CRONTASK_LOG_LEVEL" "info" # OpenIM openim-crontask 日志级别
def "OPENIM_CRONTASK_LOG_MAX_SIZE" "100" # OpenIM openim-crontask 日志最大大小MB
def "OPENIM_CRONTASK_LOG_MAX_BACKUPS" "7" # OpenIM openim-crontask 日志最大备份数
def "OPENIM_CRONTASK_LOG_MAX_AGE" "7" # OpenIM openim-crontask 日志最大保存时间(天)
def "OPENIM_CRONTASK_LOG_COMPRESS" "false" # OpenIM openim-crontask 日志是否压缩
def "OPENIM_CRONTASK_LOG_WITH_STACK" "${LOG_WITH_STACK}" # OpenIM openim-crontask 日志是否带有堆栈信息
###################### OpenIM openim-msggateway ######################
# 和上述相似,仅替换 openim-crontask 为 openim-msggateway
###################### OpenIM openim-msgtransfer ######################
# 和上述相似,仅替换 openim-crontask 为 openim-msgtransfer
###################### OpenIM openim-push ######################
# 和上述相似,仅替换 openim-crontask 为 openim-push
###################### OpenIM openim-rpc-auth ######################
# 和上述相似,仅替换 openim-crontask 为 openim-rpc-auth
###################### OpenIM openim-rpc-conversation ######################
# 和上述相似,仅替换 openim-crontask 为 openim-rpc-conversation
###################### OpenIM openim-rpc-friend ######################
# 和上述相似,仅替换 openim-crontask 为 openim-rpc-friend
###################### OpenIM openim-rpc-group ######################
# 和上述相似,仅替换 openim-crontask 为 openim-rpc-group
###################### OpenIM openim-rpc-msg ######################
# 和上述相似,仅替换 openim-crontask 为 openim-rpc-msg
###################### OpenIM openim-rpc-third ######################
# 和上述相似,仅替换 openim-crontask 为 openim-rpc-third
###################### OpenIM openim-rpc-user ######################
# 和上述相似,仅替换 openim-crontask 为 openim-rpc-user
###################### 设计中...暂时不需要######################################
# openim 配置
@ -237,4 +299,4 @@ 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}"
def "CONFIG_SERVER_CERTIFICATE_AUTHORITY" "${CA_FILE}"

@ -13,19 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# Common utilities, variables and checks for all build scripts.
set -o errexit
set +o nounset
set -o pipefail
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
#Include shell font styles and some basic information
source $SCRIPTS_ROOT/lib/init.sh
source $SCRIPTS_ROOT/path_info.sh
cd $SCRIPTS_ROOT
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
ulimit -n 200000
list1=$(cat $config_path | grep openImMessageGatewayPort | awk -F '[:]' '{print $NF}')
@ -58,7 +58,7 @@ for ((i = 0; i < ${#ws_ports[@]}; i++)); do
nohup ./${openim_msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} --config_folder_path ${configfile_path} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
done
#Check launched service process
# Check launched service process
sleep 3
check=$(ps aux | grep -w ./${openim_msggateway} | grep -v grep | wc -l)
allPorts=""

@ -13,9 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
set -o errexit
set +o nounset
set -o pipefail
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
#Include shell font styles and some basic information
source $SCRIPTS_ROOT/lib/init.sh

@ -15,9 +15,12 @@
# Common utilities, variables and checks for all build scripts.
#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
set -o errexit
set +o nounset
set -o pipefail
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
#Include shell font styles and some basic information
source $SCRIPTS_ROOT/lib/init.sh

@ -14,37 +14,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
set -o errexit
set +o nounset
set -o pipefail
#Include shell font styles and some basic information
source $SCRIPTS_ROOT/lib/init.sh
source $SCRIPTS_ROOT/path_info.sh
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
cd $SCRIPTS_ROOT
readonly SERVER_NAME="openim-crontask"
readonly SERVER_PATH="${OPENIM_OUTPUT_HOSTBIN}/openim-crontask"
echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
openim::log::status "Start OpenIM Cron, binary root: ${SERVER_NAME}"
openim::log::info "Start OpenIM Cron, path: ${SERVER_PATH}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
openim::util::stop_services_with_name ${SERVER_NAME}
#Check if the service exists
#If it is exists,kill this process
check=`ps | grep -w ./${cron_task_name} | grep -v grep| wc -l`
if [ $check -ge 1 ]
then
oldPid=`ps | grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'`
kill -9 $oldPid
fi
#Waiting port recycling
sleep 1
cd ${cron_task_binary_root}
#for ((i = 0; i < ${cron_task_service_num}; i++)); do
echo "==========================start cron_task process===========================">>$OPENIM_ROOT/logs/openIM.log
openim::log::status "start cron_task process"
nohup ./${cron_task_name} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
#done

@ -14,12 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#Include shell font styles and some basic information
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
# Common utilities, variables and checks for all build scripts.
set -o errexit
set +o nounset
set -o pipefail
#Include shell font styles and some basic information
source $SCRIPTS_ROOT/lib/init.sh
source $SCRIPTS_ROOT/path_info.sh
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
#service filename
service_filename=(

@ -90,26 +90,31 @@ IFS=" " read -ra OPENIM_SERVER_TARGETS <<< "$(openim::golang::server_targets)"
readonly OPENIM_SERVER_TARGETS
readonly OPENIM_SERVER_BINARIES=("${OPENIM_SERVER_TARGETS[@]##*/}")
# TODO: Label
START_SCRIPTS_PATH="${OPENIM_ROOT}/scripts/install/"
openim::golang::start_script_list() {
local targets=(
start_rpc_service.sh
push_start.sh
msg_transfer_start.sh
msg_gateway_start.sh
start_cron.sh
)
for target in "${targets[@]}"; do
local full_path="${START_SCRIPTS_PATH}${target}"
echo "$full_path"
chmod +x "$full_path"
done
local targets=(
start_rpc_service.sh
push_start.sh
msg_transfer_start.sh
msg_gateway_start.sh
start_cron.sh
)
local result=()
for target in "${targets[@]}"; do
result+=("${START_SCRIPTS_PATH}${target}")
done
echo "${result[@]}"
}
# Populate the OPENIM_SERVER_SCRIPT_START_LIST with the full path names of the scripts.
IFS=" " read -ra OPENIM_SERVER_SCRIPT_START_LIST <<< "$(openim::golang::start_script_list)"
readonly OPENIM_SERVER_SCRIPT_START_LIST
# Extract just the script names from the full paths.
readonly OPENIM_SERVER_SCRIPTARIES=("${OPENIM_SERVER_SCRIPT_START_LIST[@]##*/}")
openim::golang::check_openim_binaries() {
local missing_binaries=()
for binary in "${OPENIM_SERVER_BINARIES[@]}"; do

@ -246,6 +246,182 @@ openim::util::host_arch() {
echo "${host_arch}"
}
# The `openim::util::check_ports` function analyzes the state of processes based on given ports.
# It accepts multiple ports as arguments and prints:
# 1. The state of the process (whether it's running or not).
# 2. The start time of the process if it's running.
# User:
# openim::util::check_ports 8080 8081 8082
# The function returns a status of 1 if any of the processes is not running.
openim::util::check_ports() {
# An array to collect ports of processes that are not running.
not_started=()
# An array to collect information about processes that are running.
started=()
# Iterate over each given port.
for port in "$@"; do
# Use the `lsof` command to find process information related to the given port.
info=$(lsof -i :$port -n -P | grep LISTEN || true)
# If there's no process information, it means the process associated with the port is not running.
if [[ -z $info ]]; then
not_started+=($port)
else
# If there's process information, extract relevant details:
# Process ID, Command Name, and Start Time.
pid=$(echo $info | awk '{print $2}')
command=$(echo $info | awk '{print $1}')
start_time=$(ps -o lstart= -p $pid)
started+=("Port $port - Command: $command, PID: $pid, Start time: $start_time")
fi
done
# Print information about ports whose processes are not running.
if [[ ${#not_started[@]} -ne 0 ]]; then
openim::log::info "Not started ports:"
for port in "${not_started[@]}"; do
openim::log::error "Port $port is not started."
done
fi
# Print information about ports whose processes are running.
if [[ ${#started[@]} -ne 0 ]]; then
echo
openim::log::info "Started ports:"
for info in "${started[@]}"; do
openim::log::info "$info"
done
fi
# If any of the processes is not running, return a status of 1.
if [[ ${#not_started[@]} -ne 0 ]]; then
return 1
else
openim::log::success "All processes are running."
return 0
fi
}
# The `openim::util::stop_services_on_ports` function stops services running on specified ports.
# It accepts multiple ports as arguments and performs the following:
# 1. Attempts to stop any services running on the specified ports.
# 2. Prints details of services successfully stopped and those that failed to stop.
# Usage:
# openim::util::stop_services_on_ports 8080 8081 8082
# The function returns a status of 1 if any service couldn't be stopped.
openim::util::stop_services_on_ports() {
# An array to collect ports of processes that couldn't be stopped.
not_stopped=()
# An array to collect information about processes that were stopped.
stopped=()
# Iterate over each given port.
for port in "$@"; do
# Use the `lsof` command to find process information related to the given port.
info=$(lsof -i :$port -n -P | grep LISTEN || true)
# If there's process information, it means the process associated with the port is running.
if [[ -n $info ]]; then
# Extract the Process ID.
pid=$(echo $info | awk '{print $2}')
# Try to stop the service by killing its process.
if kill -TERM $pid; then
stopped+=($port)
else
not_stopped+=($port)
fi
fi
done
# Print information about ports whose processes couldn't be stopped.
if [[ ${#not_stopped[@]} -ne 0 ]]; then
openim::log::info "Ports that couldn't be stopped:"
for port in "${not_stopped[@]}"; do
openim::log::error "Failed to stop service on port $port."
done
fi
# Print information about ports whose processes were successfully stopped.
if [[ ${#stopped[@]} -ne 0 ]]; then
echo
openim::log::info "Stopped services on ports:"
for port in "${stopped[@]}"; do
openim::log::info "Successfully stopped service on port $port."
done
fi
# If any of the processes couldn't be stopped, return a status of 1.
if [[ ${#not_stopped[@]} -ne 0 ]]; then
return 1
else
openim::log::success "All specified services were stopped."
return 0
fi
}
# The `openim::util::stop_services_with_name` function stops services with specified names.
# It accepts multiple service names as arguments and performs the following:
# 1. Attempts to stop any services with the specified names.
# 2. Prints details of services successfully stopped and those that failed to stop.
# Usage:
# openim::util::stop_services_with_name nginx apache
# The function returns a status of 1 if any service couldn't be stopped.
openim::util::stop_services_with_name() {
# An array to collect names of processes that couldn't be stopped.
not_stopped=()
# An array to collect information about processes that were stopped.
stopped=()
# Iterate over each given service name.
for name in "$@"; do
# Use the `pgrep` command to find process IDs related to the given service name.
pids=$(pgrep -f $name)
for pid in $pids; do
# If there's a Process ID, it means the service with the name is running.
if [[ -n $pid ]]; then
# Try to stop the service by killing its process.
if kill -TERM $pid; then
stopped+=($name)
else
not_stopped+=($name)
fi
fi
done
done
# Print information about services whose processes couldn't be stopped.
if [[ ${#not_stopped[@]} -ne 0 ]]; then
openim::log::info "Services that couldn't be stopped:"
for name in "${not_stopped[@]}"; do
openim::log::error "Failed to stop the $name service."
done
fi
# Print information about services whose processes were successfully stopped.
if [[ ${#stopped[@]} -ne 0 ]]; then
echo
openim::log::info "Stopped services:"
for name in "${stopped[@]}"; do
openim::log::info "Successfully stopped the $name service."
done
fi
# If any of the services couldn't be stopped, return a status of 1.
if [[ ${#not_stopped[@]} -ne 0 ]]; then
return 1
else
openim::log::success "All specified services were stopped."
return 0
fi
}
# This figures out the host platform without relying on golang. We need this as
# we don't want a golang install to be a prerequisite to building yet we need
# this info to figure out where the final binaries are placed.

@ -1,58 +1,3 @@
#!/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.
# Determine the architecture and version
architecture=$(uname -m)
version=$(uname -s | tr '[:upper:]' '[:lower:]')
#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $SCRIPTS_ROOT/lib/color.sh
cd $SCRIPTS_ROOT
# Define the supported architectures and corresponding bin directories
declare -A supported_architectures=(
["linux-amd64"]="_output/bin/platforms/linux/amd64"
["linux-arm64"]="_output/bin/platforms/linux/arm64"
["linux-mips64"]="_output/bin/platforms/linux/mips64"
["linux-mips64le"]="_output/bin/platforms/linux/mips64le"
["linux-ppc64le"]="_output/bin/platforms/linux/ppc64le"
["linux-s390x"]="_output/bin/platforms/linux/s390x"
["darwin-amd64"]="_output/bin/platforms/darwin/amd64"
["windows-amd64"]="_output/bin/platforms/windows/amd64"
["linux-x86_64"]="_output/bin/platforms/linux/amd64" # Alias for linux-amd64
["darwin-x86_64"]="_output/bin/platforms/darwin/amd64" # Alias for darwin-amd64
)
# Check if the architecture and version are supported
if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then
echo -e "${BLUE_PREFIX}================> Unsupported architecture: $architecture or version: $version${COLOR_SUFFIX}"
exit 1
fi
echo -e "${BLUE_PREFIX}================> Architecture: $architecture${COLOR_SUFFIX}"
# Set the BIN_DIR based on the architecture and version
BIN_DIR=${supported_architectures["$version-$architecture"]}
echo -e "${BLUE_PREFIX}================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR${COLOR_SUFFIX}"
# Don't put the space between "="
openim_msggateway="openim-msggateway"
msg_gateway_binary_root="$OPENIM_ROOT/$BIN_DIR"
@ -77,30 +22,6 @@ cmd_utils_binary_root="$OPENIM_ROOT/$BIN_DIR"
# Global configuration file default dir
config_path="$OPENIM_ROOT/config/config.yaml"
configfile_path="$OPENIM_ROOT/config"
log_path="$OPENIM_ROOT/log"
component_check="component"
component_check_binary_root="$OPENIM_ROOT/$BIN_DIR_TOOLS"
# servicefile dir path
service_source_root=(
# api service file
"$OPENIM_ROOT/cmd/api/"
# rpc service file
"$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-user/"
"$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-friend/"
"$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-group/"
"$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-auth/"
"$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-conversation/"
"$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-third/"
"$OPENIM_ROOT/cmd/openim-crontask"
"${msg_gateway_source_root}"
"${msg_transfer_source_root}"
"${msg_source_root}"
"${push_source_root}"
# "${sdk_server_source_root}"
)
# service filename
service_names=(

@ -20,26 +20,39 @@ set -o nounset
set -o pipefail
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh"
source "${OPENIM_ROOT}/scripts/install/common.sh"
set +o errexit
openim::golang::check_openim_binaries
if [[ $? -ne 0 ]]; then
openim::log::error "OpenIM binaries are not found. Please run 'make' to build binaries."
openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries."
${OPENIM_ROOT}/scripts/build_all_service.sh
fi
set -o errexit
scripts_to_run=$(openim::golang::start_script_list)
echo "You need to start the following scripts in order: ${OPENIM_SERVER_SCRIPTARIES[@]}"
openim::log::install_errexit
for script in $scripts_to_run; do
openim::log::info "Executing: $script"
"$script"
if [ $? -ne 0 ]; then
# Print error message and exit
openim::log::error "Error executing ${i}. Exiting..."
exit -1
fi
done
# Function to execute the scripts.
function execute_scripts() {
for script_path in "${OPENIM_SERVER_SCRIPT_START_LIST[@]}"; do
# Check if the script file exists and is executable.
if [[ -x "$script_path" ]]; then
openim::log::status "Starting script: ${script_path##*/}" # Log the script name.
# Execute the script.
"$script_path"
openim::log::success "OpenIM Server has been started successfully!"
# Check if the script executed successfully.
if [[ $? -eq 0 ]]; then
openim::log::info "${script_path##*/} executed successfully."
else
openim::log::errexit "Error executing ${script_path##*/}."
fi
else
openim::log::errexit "Script ${script_path##*/} is missing or not executable."
fi
done
}
execute_scripts

@ -13,29 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# This script is stop all openim service
#
# Usage: `scripts/stop.sh`.
# Encapsulated as: `make stop`.
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/lib/init.sh
source $OPENIM_ROOT/scripts/path_info.sh
set -o errexit
set -o nounset
set -o pipefail
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/install/common.sh"
cd "$SCRIPTS_ROOT"
echo "Ready to stop port: ${OPENIM_SERVER_PORT_LISTARIES[@]}"
for i in ${service_names[*]}; do
#Check whether the service exists
name="ps -aux |grep -w $i |grep -v grep"
count="${name}| wc -l"
if [ $(eval ${count}) -gt 0 ]; then
pid="${name}| awk '{print \$2}'"
echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}"
#kill the service that existed
kill -9 $(eval $pid)
echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}"
fi
done
openim::util::stop_services_on_ports ${OPENIM_SERVER_PORT_LISTARIES[@]}
Loading…
Cancel
Save