mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-06 18:15:59 +08:00
feat: add sctips help
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
@@ -1,46 +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.
|
||||
|
||||
version=errcode
|
||||
repository=${1}
|
||||
if [[ -z ${repository} ]]
|
||||
then
|
||||
echo "repository is empty"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set +e
|
||||
echo "repository: ${repository}"
|
||||
source ./path_info.sh
|
||||
echo "start to build docker images"
|
||||
currentPwd=`pwd`
|
||||
echo ${currentPwd}
|
||||
i=0
|
||||
for path in ${service_source_root[*]}
|
||||
do
|
||||
cd ${path}
|
||||
make build
|
||||
image="${repository}/${image_names[${i}]}:$version"
|
||||
echo ${image}
|
||||
docker build -t $image . -f ./deploy.Dockerfile
|
||||
echo "build ${image} success"
|
||||
docker push ${image}
|
||||
echo "push ${image} success"
|
||||
echo "=============================="
|
||||
i=$((i + 1))
|
||||
cd ${currentPwd}
|
||||
done
|
||||
|
||||
echo "build all images success"
|
||||
@@ -49,8 +49,8 @@ for i in ${service_port_name[*]}; do
|
||||
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
|
||||
echo -e ${BACKGROUND_GREEN}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${BACKGROUND_GREEN}${j}${COLOR_SUFFIX}
|
||||
echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX}
|
||||
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}
|
||||
|
||||
@@ -29,8 +29,8 @@ 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"
|
||||
["${OPENIM_ROOT}/deployments/templates/env_template.yaml"]="${OPENIM_OUTPUT_SUBPATH}/bin/.env"
|
||||
["${OPENIM_ROOT}/deployments/templates/openim.yaml"]="${OPENIM_OUTPUT_SUBPATH}/bin/openim_config.yaml"
|
||||
)
|
||||
|
||||
for template in "${!TEMPLATES[@]}"; do
|
||||
|
||||
@@ -30,6 +30,10 @@ 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={
|
||||
|
||||
}
|
||||
|
||||
# Execute commands that require root permission without entering a password
|
||||
function openim::common::sudo {
|
||||
echo ${LINUX_PASSWORD} | sudo -S $1
|
||||
|
||||
@@ -164,7 +164,8 @@ 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
|
||||
# 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主密钥
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
# limitations under the License.
|
||||
|
||||
#Include shell font styles and some basic information
|
||||
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
|
||||
|
||||
#Include shell font styles and some basic information
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
# The golang package that we are building.
|
||||
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
|
||||
readonly KUBE_GO_PACKAGE=github.com/openimsdk/open-im-server
|
||||
readonly KUBE_GOPATH="${KUBE_GOPATH:-"${KUBE_OUTPUT}/go"}"
|
||||
export KUBE_GOPATH
|
||||
@@ -89,6 +90,45 @@ IFS=" " read -ra OPENIM_SERVER_TARGETS <<< "$(openim::golang::server_targets)"
|
||||
readonly OPENIM_SERVER_TARGETS
|
||||
readonly OPENIM_SERVER_BINARIES=("${OPENIM_SERVER_TARGETS[@]##*/}")
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
IFS=" " read -ra OPENIM_SERVER_SCRIPT_START_LIST <<< "$(openim::golang::start_script_list)"
|
||||
readonly OPENIM_SERVER_SCRIPT_START_LIST
|
||||
|
||||
openim::golang::check_openim_binaries() {
|
||||
local missing_binaries=()
|
||||
for binary in "${OPENIM_SERVER_BINARIES[@]}"; do
|
||||
if [[ ! -x "${OPENIM_OUTPUT_HOSTBIN}/${binary}" ]]; then
|
||||
missing_binaries+=("${binary}")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#missing_binaries[@]} -ne 0 ]]; then
|
||||
echo "The following binaries were not found in ${OPENIM_OUTPUT_HOSTBIN}:"
|
||||
for missing in "${missing_binaries[@]}"; do
|
||||
echo " - ${missing}"
|
||||
done
|
||||
return 1
|
||||
else
|
||||
echo "All binaries have been installed in ${OPENIM_OUTPUT_HOSTBIN}。"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
openim::golang::tools_targets() {
|
||||
local targets=(
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ OPENIM_OUTPUT_SUBPATH="${OPENIM_OUTPUT_SUBPATH:-_output}"
|
||||
OPENIM_OUTPUT="${OPENIM_ROOT}/${OPENIM_OUTPUT_SUBPATH}"
|
||||
|
||||
OPENIM_OUTPUT_BINPATH="${OPENIM_OUTPUT}/bin/platforms"
|
||||
OPENIM_OUTPUT_BINTOOLPATH="${OPENIM_OUTPUT}/bin-tools"
|
||||
OPENIM_OUTPUT_BINTOOLPATH="${OPENIM_OUTPUT}/bin/tools"
|
||||
OPENIM_OUTPUT_TOOLS="${OPENIM_OUTPUT}/tools"
|
||||
OPENIM_OUTPUT_TMP="${OPENIM_OUTPUT}/tmp"
|
||||
OPENIM_OUTPUT_LOGS="${OPENIM_OUTPUT}/logs"
|
||||
|
||||
@@ -48,7 +48,7 @@ endif
|
||||
|
||||
# BIN_TOOLS_DIR: Directory where executable files are stored.
|
||||
ifeq ($(origin BIN_TOOLS_DIR),undefined)
|
||||
BIN_TOOLS_DIR := $(OUTPUT_DIR)/bin-tools
|
||||
BIN_TOOLS_DIR := $(BIN_DIR)/tools
|
||||
$(shell mkdir -p $(BIN_TOOLS_DIR))
|
||||
endif
|
||||
|
||||
@@ -71,7 +71,7 @@ $(shell mkdir -p $(TMP_DIR))
|
||||
endif
|
||||
|
||||
ifeq ($(origin VERSION), undefined)
|
||||
# VERSION := $(shell git describe --abbrev=0 --dirty --always --tags | sed 's/-/./g') #v2.3.3.dirty
|
||||
# VERSION := $(shell git describe --tags --always --match='v*')
|
||||
# git describe --tags --always --match="v*" --dirty
|
||||
VERSION := $(shell git describe --tags --always --match="v*" --dirty | sed 's/-/./g') #v2.3.3.631.g00abdc9b.dirty
|
||||
# v2.3.3: git tag
|
||||
|
||||
+19
-16
@@ -14,7 +14,6 @@
|
||||
|
||||
# ==============================================================================
|
||||
# Makefile helper functions for docker image
|
||||
# TODO: For the time being only used for compilation, it can be arm or amd, please do not delete it, it can be extended with new functions
|
||||
# ==============================================================================
|
||||
# Path: scripts/make-rules/image.mk
|
||||
# docker registry: registry.example.com/namespace/image:tag as: registry.hub.docker.com/cubxxw/<image-name>:<tag>
|
||||
@@ -24,8 +23,11 @@
|
||||
DOCKER := docker
|
||||
DOCKER_SUPPORTED_API_VERSION ?= 1.32|1.40|1.41
|
||||
|
||||
REGISTRY_PREFIX ?= ghcr.io/OpenIMSDK
|
||||
IMAGES ?= lvscare
|
||||
# read: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/images.md
|
||||
REGISTRY_PREFIX ?= ghcr.io/openimsdk
|
||||
|
||||
BASE_IMAGE ?= ghcr.io/openim-sigs/openim-bash-image
|
||||
|
||||
IMAGE_PLAT ?= $(subst $(SPACE),$(COMMA),$(subst _,/,$(PLATFORMS)))
|
||||
|
||||
EXTRA_ARGS ?= --no-cache
|
||||
@@ -102,25 +104,26 @@ image.build.multiarch: image.verify $(foreach p,$(PLATFORMS),$(addprefix image.b
|
||||
|
||||
## image.build.%: Build docker image for a specific platform
|
||||
.PHONY: image.build.%
|
||||
image.build.%: go.bin.%
|
||||
image.build.%: go.build.%
|
||||
$(eval IMAGE := $(COMMAND))
|
||||
$(eval IMAGE_PLAT := $(subst _,/,$(PLATFORM)))
|
||||
$(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
|
||||
@echo "===========> Building LOCAL docker image $(IMAGE) $(VERSION) for $(IMAGE_PLAT)"
|
||||
@echo "===========> Building docker image $(IMAGE) $(VERSION) for $(IMAGE_PLAT)"
|
||||
@mkdir -p $(TMP_DIR)/$(IMAGE)/$(PLATFORM)
|
||||
@cat $(ROOT_DIR)/docker/$(IMAGE)/Dockerfile\
|
||||
>$(TMP_DIR)/$(IMAGE)/Dockerfile
|
||||
@cp $(BIN_DIR)/$(PLATFORM)/$(IMAGE) $(TMP_DIR)/$(IMAGE)/$(PLATFORM)
|
||||
|
||||
$(eval BUILD_SUFFIX := --load --pull -t $(REGISTRY_PREFIX)/$(IMAGE):$(VERSION) $(TMP_DIR)/$(IMAGE))
|
||||
$(eval BUILD_SUFFIX_ARM := --load --pull -t $(REGISTRY_PREFIX)/$(IMAGE).$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE))
|
||||
@if [ "$(ARCH)" == "amd64" ]; then \
|
||||
echo "===========> Creating LOCAL docker image tag $(REGISTRY_PREFIX)/$(IMAGE):$(VERSION) for $(ARCH)"; \
|
||||
$(DOCKER) buildx build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX); \
|
||||
@awk '/FROM/ {c++; if (c==2) {print; next}} c>=2' $(ROOT_DIR)/build/images/$(IMAGE)/Dockerfile \
|
||||
| sed -e "s#BASE_IMAGE#$(BASE_IMAGE)#g" \
|
||||
-e 's/--from=builder //g' \
|
||||
-e 's#COPY /openim/openim-server/#COPY ./#g' > $(TMP_DIR)/$(IMAGE)/Dockerfile
|
||||
@cp $(BIN_DIR)/platforms/$(IMAGE_PLAT)/$(IMAGE) $(TMP_DIR)/$(IMAGE)
|
||||
$(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE))
|
||||
@if [ $(shell $(GO) env GOARCH) != $(ARCH) ] ; then \
|
||||
$(MAKE) image.daemon.verify ;\
|
||||
$(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) ; \
|
||||
else \
|
||||
echo "===========> Creating LOCAL docker image tag $(REGISTRY_PREFIX)/$(IMAGE).$(ARCH):$(VERSION) for $(ARCH)"; \
|
||||
$(DOCKER) buildx build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX_ARM); \
|
||||
$(DOCKER) build $(BUILD_SUFFIX) ; \
|
||||
fi
|
||||
@rm -rf $(TMP_DIR)/$(IMAGE)
|
||||
|
||||
|
||||
# https://docs.docker.com/build/building/multi-platform/
|
||||
# busybox image supports amd64, arm32v5, arm32v6, arm32v7, arm64v8, i386, ppc64le, and s390x
|
||||
|
||||
@@ -40,19 +40,6 @@ declare -A supported_architectures=(
|
||||
["darwin-x86_64"]="_output/bin/platforms/darwin/amd64" # Alias for darwin-amd64
|
||||
)
|
||||
|
||||
declare -A supported_architectures_tools=(
|
||||
["linux-amd64"]="_output/bin-tools/platforms/linux/amd64"
|
||||
["linux-arm64"]="_output/bin-tools/platforms/linux/arm64"
|
||||
["linux-mips64"]="_output/bin-tools/platforms/linux/mips64"
|
||||
["linux-mips64le"]="_output/bin-tools/platforms/linux/mips64le"
|
||||
["linux-ppc64le"]="_output/bin-tools/platforms/linux/ppc64le"
|
||||
["linux-s390x"]="_output/bin-tools/platforms/linux/s390x"
|
||||
["darwin-amd64"]="_output/bin-tools/platforms/darwin/amd64"
|
||||
["windows-amd64"]="_output/bin-tools/platforms/windows/amd64"
|
||||
["linux-x86_64"]="_output/bin-tools/platforms/linux/amd64" # Alias for linux-amd64
|
||||
["darwin-x86_64"]="_output/bin-tools/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}"
|
||||
@@ -63,18 +50,15 @@ echo -e "${BLUE_PREFIX}================> Architecture: $architecture${COLOR_SUFF
|
||||
|
||||
# Set the BIN_DIR based on the architecture and version
|
||||
BIN_DIR=${supported_architectures["$version-$architecture"]}
|
||||
BIN_DIR_TOOLS=${supported_architectures_tools["$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"
|
||||
msg_gateway_source_root="$OPENIM_ROOT/cmd/openim-msggateway/"
|
||||
|
||||
msg_name="openim-rpc-msg"
|
||||
msg_binary_root="$OPENIM_ROOT/$BIN_DIR"
|
||||
msg_source_root="$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-msg/"
|
||||
|
||||
push_name="openim-push"
|
||||
push_binary_root="$OPENIM_ROOT/$BIN_DIR"
|
||||
@@ -82,16 +66,13 @@ push_source_root="$OPENIM_ROOT/cmd/openim-push/"
|
||||
|
||||
openim_msgtransfer="openim-msgtransfer"
|
||||
msg_transfer_binary_root="$OPENIM_ROOT/$BIN_DIR"
|
||||
msg_transfer_source_root="$OPENIM_ROOT/cmd/openim-msgtransfer/"
|
||||
msg_transfer_service_num=4
|
||||
|
||||
cron_task_name="openim-crontask"
|
||||
cron_task_binary_root="$OPENIM_ROOT/$BIN_DIR"
|
||||
cron_task_source_root="$OPENIM_ROOT/cmd/openim-crontask/"
|
||||
|
||||
cmd_utils_name="openim-cmdutils"
|
||||
cmd_utils_binary_root="$OPENIM_ROOT/$BIN_DIR"
|
||||
cmd_utils_source_root="$OPENIM_ROOT/cmd/openim-cmdutils/"
|
||||
|
||||
# Global configuration file default dir
|
||||
config_path="$OPENIM_ROOT/config/config.yaml"
|
||||
|
||||
+12
-53
@@ -16,69 +16,28 @@
|
||||
#FIXME This script is the startup script for multiple servers.
|
||||
#FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||
|
||||
if [ ! -d "${OPENIM_ROOT}/_output/bin/platforms" ]; then
|
||||
# exec build_all_service.sh
|
||||
"${SCRIPTS_ROOT}/build_all_service.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_ROOT}/scripts/build_all_service.sh
|
||||
fi
|
||||
set -o errexit
|
||||
|
||||
bin_dir="$OPENIM_ROOT/_output/bin"
|
||||
logs_dir="$OPENIM_ROOT/logs"
|
||||
scripts_to_run=$(openim::golang::start_script_list)
|
||||
|
||||
if [ ! -d "$bin_dir" ]; then
|
||||
mkdir -p "$bin_dir"
|
||||
fi
|
||||
|
||||
if [ ! -d "$logs_dir" ]; then
|
||||
mkdir -p "$logs_dir"
|
||||
fi
|
||||
|
||||
|
||||
cd $SCRIPTS_ROOT
|
||||
|
||||
# FIXME Put the shell script names here
|
||||
need_to_start_server_shell=(
|
||||
start_rpc_service.sh
|
||||
push_start.sh
|
||||
msg_transfer_start.sh
|
||||
msg_gateway_start.sh
|
||||
start_cron.sh
|
||||
)
|
||||
|
||||
component_check=start_component_check.sh
|
||||
echo -e ""
|
||||
chmod +x $component_check
|
||||
echo -e "=========> ${BACKGROUND_GREEN}Executing ${component_check}...${COLOR_SUFFIX}"
|
||||
echo -e ""
|
||||
./$component_check
|
||||
if [ $? -ne 0 ]; then
|
||||
# Print error message and exit
|
||||
echo -e "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
# Loop through the script names and execute them
|
||||
for i in ${need_to_start_server_shell[*]}; do
|
||||
chmod +x $i
|
||||
|
||||
echo -e ""
|
||||
# Print script execution message
|
||||
echo -e "=========> ${BACKGROUND_GREEN}Executing ${i}...${COLOR_SUFFIX}"
|
||||
echo -e ""
|
||||
|
||||
./$i
|
||||
|
||||
# Check if the script executed successfully
|
||||
if [ $? -ne 0 ]; then
|
||||
for script in $scripts_to_run; do
|
||||
openim::log::info "Executing: $script"
|
||||
"$script"
|
||||
if [ $? -ne 0 ]; then
|
||||
# Print error message and exit
|
||||
echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${i}. Exiting...${COLOR_SUFFIX}"
|
||||
openim::log::error "Error executing ${i}. Exiting..."
|
||||
exit -1
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user