feat: save all file

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong(cubxxw-openim)
2023-08-15 22:07:43 +08:00
parent 2518985e43
commit 202b1dfdae
8 changed files with 1015 additions and 148 deletions
+2
View File
@@ -137,6 +137,8 @@ def "API_OPENIM_PORT" "10002" # API的开放端口
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消息服务端口
-103
View File
@@ -1,103 +0,0 @@
#!/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.
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
SERVER_NAME="openim-crontask"
openim::log::status "Start OpenIM Cron, binary root: ${SERVER_NAME}"
openim::log::info "Start OpenIM Cron, path: ${OPENIM_CRONTASK_BINARY}"
# openim::util::stop_services_with_name ${SERVER_NAME}
# sleep 1
# openim::log::status "start cron_task process, path: ${OPENIM_CRONTASK_BINARY}"
# nohup ${OPENIM_CRONTASK_BINARY} >>${LOG_FILE} 2>&1 &
# openim::util::check_process_names ${SERVER_NAME}
# # Print the necessary information after installation
# function openim::crontask::info() {
# cat << EOF
# openim-crontask listen on: ${OPENIM_CRONTASK_HOST}
# EOF
# }
# install openim-crontask
function openim::crontask::install()
{
pushd ${OPENIM_ROOT}
# 1. Build openim-crontask
make build BINS=${SERVER_NAME}
openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
# 2. Generate and install the openim-crontask configuration file (openim-crontask.yaml)
echo ${LINUX_PASSWORD} | sudo -S bash -c \
"./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim-crontask.yaml > ${OPENIM_CONFIG_DIR}/openim-crontask.yaml"
# 3. Create and install the openim-crontask systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
"./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/openim-crontask.service > /etc/systemd/system/openim-crontask.service"
# 4. Start the openim-crontask service
openim::common::sudo "systemctl daemon-reload"
openim::common::sudo "systemctl restart openim-crontask"
openim::common::sudo "systemctl enable openim-crontask"
openim::crontask::status || return 1
openim::crontask::info
openim::log::info "install openim-crontask successfully"
popd
}
# Unload
function openim::crontask::uninstall()
{
set +o errexit
openim::common::sudo "systemctl stop openim-crontask"
openim::common::sudo "systemctl disable openim-crontask"
openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/openim-crontask"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/openim-crontask.yaml"
openim::common::sudo "rm -f /etc/systemd/system/openim-crontask.service"
set -o errexit
openim::log::info "uninstall openim-crontask successfully"
}
# Status Check
function openim::crontask::status()
{
# 查看 openim-crontask 运行状态,如果输出中包含 active (running) 字样说明 openim-crontask 成功启动。
systemctl status openim-crontask|grep -q 'active' || {
openim::log::error "openim-crontask failed to start, maybe not installed properly"
return 1
}
# 监听端口在配置文件中是 hardcode
if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then
openim::log::error "cannot access health check port, openim-crontask maybe not startup"
return 1
fi
}
if [[ "$*" =~ openim::crontask:: ]];then
eval $*
fi
+88 -5
View File
@@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Common utilities, variables and checks for all build scripts.
set -o errexit
set +o nounset
set -o pipefail
@@ -22,9 +20,94 @@ 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
SERVER_NAME="openim-push"
# openim::log::status "Start OpenIM Push, binary root: ${SERVER_NAME}"
# openim::log::info "Start OpenIM Push, path: ${OPENIM_PUSH_BINARY}"
# openim::util::stop_services_with_name ${SERVER_NAME}
# openim::log::status "start push process, path: ${OPENIM_PUSH_BINARY}"
# nohup ${OPENIM_PUSH_BINARY} >>${LOG_FILE} 2>&1 &
# openim::util::check_process_names ${SERVER_NAME}
###################################### Linux Systemd ######################################
SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service"
# Print the necessary information after installation
function openim::push::info() {
cat << EOF
openim-push listen on: ${OPENIM_PUSH_HOST}
EOF
}
# install openim-push
function openim::push::install()
{
pushd ${OPENIM_ROOT}
# 1. Build openim-push
make build BINS=${SERVER_NAME}
openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
# 2. Generate and install the openim-push configuration file (openim-push.yaml)
echo ${LINUX_PASSWORD} | sudo -S bash -c \
"./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
# 3. Create and install the ${SERVER_NAME} systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
"./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}"
openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
# 4. Start the openim-push service
openim::common::sudo "systemctl daemon-reload"
openim::common::sudo "systemctl restart ${SERVER_NAME}"
openim::common::sudo "systemctl enable ${SERVER_NAME}"
openim::push::status || return 1
openim::push::info
openim::log::info "install ${SERVER_NAME} successfully"
popd
}
# Unload
function openim::push::uninstall()
{
set +o errexit
openim::common::sudo "systemctl stop ${SERVER_NAME}"
openim::common::sudo "systemctl disable ${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
set -o errexit
openim::log::info "uninstall ${SERVER_NAME} successfully"
}
# Status Check
function openim::push::status()
{
# Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully.
systemctl status ${SERVER_NAME}|grep -q 'active' || {
openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly"
return 1
}
# The listening port is hardcode in the configuration file
if echo | telnet 127.0.0.1 7071 2>&1|grep refused &>/dev/null;then # Assuming a different port for push
openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup"
return 1
fi
}
if [[ "$*" =~ ${SERVER_NAME}:: ]];then
eval $*
fi
cd $SCRIPTS_ROOT