mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-10 12:05:58 +08:00
refactor: 3.7.0 code conventions. (#2148)
* Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * feat: add code lint * feat: add code lint * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * feat: code format * Script Refactoring * Script Refactoring * Script Refactoring * Adjust MinIO configuration settings * Adjust configuration settings * Adjust configuration settings * refactor: config change. * refactor: webhooks update. * Adjust configuration settings * refactor: webhooks update. * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * feat: s3 api addr * refactor: webhooks update. * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * refactor: webhooks update. * refactor: kafka update. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * refactor: kafka update. * refactor: kafka update. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * Windows can compile and run. * Windows can compile and run. * refactor: kafka update. * feat: msg cache split * refactor: webhooks update * refactor: webhooks update * refactor: friends update * refactor: group update * refactor: third update * refactor: api update * refactor: crontab update * refactor: msggateway update * mage * mage * refactor: all module update. * check * refactor: all module update. * load config * load config * load config * load config * refactor: all module update. * refactor: all module update. * refactor: all module update. * refactor: all module update. * refactor: all module update. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * refactor: all module update. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * update tools * update tools * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * update protocol * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: api remove token auth by redis directly. * Code Refactoring * refactor: websocket auth change to call rpc of auth. * refactor: kick online user and remove token change to call auth rpc. * refactor: kick online user and remove token change to call auth rpc. * refactor: remove msggateway redis. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor webhook * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor webhook * refactor: cmd update. * refactor: cmd update. * fix: runtime: goroutine stack exceeds * refactor: cmd update. * refactor notification * refactor notification * refactor * refactor: cmd update. * refactor: cmd update. * refactor * refactor * refactor * protojson * protojson * protojson * go mod * wrapperspb * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: context update. * refactor: websocket update info. * refactor: websocket update info. * refactor: websocket update info. * refactor: websocket update info. * refactor: api name change. * refactor: debug info. * refactor: debug info. * refactor: debug info. * fix: update file * refactor * refactor * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * fix: callback update. * fix: callback update. * refactor * fix: update message. * fix: msg cache timeout. * refactor * refactor * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: websocket handle error remove when upgrade error. --------- Co-authored-by: skiffer-git <44203734@qq.com> Co-authored-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> Co-authored-by: withchao <993506633@qq.com>
This commit is contained in:
+20
-18
@@ -20,9 +20,6 @@
|
||||
# READ: https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${OPENIM_ROOT}/scripts/install/common.sh"
|
||||
|
||||
@@ -33,7 +30,7 @@ fi
|
||||
|
||||
OPENIM_VERBOSE=4
|
||||
|
||||
openim::log::info "\n# Begin to check all openim service"
|
||||
openim::log::info "\n# Begin to check all OpenIM service"
|
||||
|
||||
openim::log::status "Check all dependent service ports"
|
||||
# Elegant printing function
|
||||
@@ -65,16 +62,16 @@ print_services_and_ports "${OPENIM_SERVER_NAME_TARGETS[@]}" "${OPENIM_SERVER_POR
|
||||
print_services_and_ports "${OPENIM_DEPENDENCY_TARGETS[@]}" "${OPENIM_DEPENDENCY_PORT_TARGETS[@]}"
|
||||
|
||||
# OpenIM check
|
||||
echo "++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}"
|
||||
openim::log::info "\n## Check all dependent service ports"
|
||||
echo "++ The port being checked: ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}"
|
||||
#echo "++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}"
|
||||
openim::log::info "\n## Check all dependent components service ports"
|
||||
#echo "++ The port being checked: ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}"
|
||||
|
||||
|
||||
# Later, after discarding Docker, the Docker keyword is unreliable, and Kubepods is used
|
||||
if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then
|
||||
openim::color::echo ${COLOR_CYAN} "Environment in the interior of the container"
|
||||
else
|
||||
openim::color::echo ${COLOR_CYAN} "The environment is outside the container"
|
||||
openim::color::echo ${COLOR_CYAN}"The environment is outside the container"
|
||||
openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}
|
||||
fi
|
||||
|
||||
@@ -82,30 +79,35 @@ if [[ $? -ne 0 ]]; then
|
||||
openim::log::error_exit "The service does not start properly, please check the port, query variable definition!"
|
||||
echo "+++ https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh +++"
|
||||
else
|
||||
openim::log::success "All components depended on by openim are running normally! "
|
||||
openim::log::success "All components depended on by OpenIM are running normally! "
|
||||
fi
|
||||
|
||||
|
||||
openim::log::info "\n## Check openim service name:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer"
|
||||
openim::log::status "Check OpenIM service:"
|
||||
openim::log::colorless "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer"
|
||||
result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "+++ cat openim log file >>> ${LOG_FILE}"
|
||||
openim::log::error "check process failed.\n $result"
|
||||
#echo "+++ cat openim log file >>> ${LOG_FILE}"
|
||||
|
||||
openim::log::error "The service is not running properly, please check the logs $result"
|
||||
fi
|
||||
|
||||
|
||||
echo "Check openim service name:"
|
||||
openim::log::status "Check OpenIM service:"
|
||||
for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do
|
||||
echo "$item"
|
||||
openim::log::colorless "$item"
|
||||
done
|
||||
|
||||
|
||||
result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]})
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "+++ cat openim log file >>> ${LOG_FILE}"
|
||||
openim::log::error "check process failed.\n "
|
||||
#echo "+++ cat OpenIM log file >>> ${LOG_FILE}"
|
||||
openim::log::error "The service is not running properly, please check the logs "
|
||||
echo "$result"
|
||||
exit 1
|
||||
else
|
||||
openim::log::success "All openim services are running normally! "
|
||||
openim::log::status "List the ports listened to by the OpenIM service:"
|
||||
openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}
|
||||
openim::util::find_ports_for_all_services ${OPENIM_MSGTRANSFER_BINARY[@]}
|
||||
openim::log::success "All OpenIM services are running normally! "
|
||||
fi
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ DRY_RUN=${DRY_RUN:-""}
|
||||
REGENERATE_DOCS=${REGENERATE_DOCS:-""}
|
||||
UPSTREAM_REMOTE=${UPSTREAM_REMOTE:-upstream}
|
||||
FORK_REMOTE=${FORK_REMOTE:-origin}
|
||||
MAIN_REPO_ORG=${MAIN_REPO_ORG:-$(git remote get-url "$UPSTREAM_REMOTE" | awk '{gsub(/http[s]:\/\/|git@/,"")}1' | awk -F'[@:./]' 'NR==1{print $3}')}
|
||||
MAIN_REPO_NAME=${MAIN_REPO_NAME:-$(git remote get-url "$UPSTREAM_REMOTE" | awk '{gsub(/http[s]:\/\/|git@/,"")}1' | awk -F'[@:./]' 'NR==1{print $4}')}
|
||||
MAIN_REPO_ORG=${MAIN_REPO_ORG:-$(git remote get-url "$UPSTREAM_REMOTE" | awk '{gsub(/webhook[s]:\/\/|git@/,"")}1' | awk -F'[@:./]' 'NR==1{print $3}')}
|
||||
MAIN_REPO_NAME=${MAIN_REPO_NAME:-$(git remote get-url "$UPSTREAM_REMOTE" | awk '{gsub(/webhook[s]:\/\/|git@/,"")}1' | awk -F'[@:./]' 'NR==1{print $4}')}
|
||||
|
||||
if [[ -z ${GITHUB_USER:-} ]]; then
|
||||
openim::log::error_exit "Please export GITHUB_USER=<your-user> (or GH organization, if that's where your fork lives)"
|
||||
|
||||
+36
-8
@@ -14,14 +14,42 @@
|
||||
# limitations under the License.
|
||||
|
||||
# Wait for Kafka to be ready
|
||||
until /opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092; do
|
||||
echo "Waiting for Kafka to be ready..."
|
||||
sleep 2
|
||||
|
||||
KAFKA_SERVER=localhost:9092
|
||||
|
||||
MAX_ATTEMPTS=300
|
||||
attempt_num=1
|
||||
|
||||
echo "Waiting for Kafka to be ready..."
|
||||
|
||||
until /opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server $KAFKA_SERVER; do
|
||||
echo "Attempt $attempt_num of $MAX_ATTEMPTS: Kafka not ready yet..."
|
||||
if [ $attempt_num -eq $MAX_ATTEMPTS ]; then
|
||||
echo "Kafka not ready after $MAX_ATTEMPTS attempts, exiting"
|
||||
exit 1
|
||||
fi
|
||||
attempt_num=$((attempt_num+1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Create topics
|
||||
/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic latestMsgToRedis
|
||||
/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic msgToPush
|
||||
/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic offlineMsgToMongoMysql
|
||||
echo "Kafka is ready. Creating topics..."
|
||||
|
||||
echo "Topics created."
|
||||
|
||||
topics=("toRedis" "toMongo" "toPush")
|
||||
partitions=8
|
||||
replicationFactor=1
|
||||
|
||||
for topic in "${topics[@]}"; do
|
||||
if /opt/bitnami/kafka/bin/kafka-topics.sh --create \
|
||||
--bootstrap-server $KAFKA_SERVER \
|
||||
--replication-factor $replicationFactor \
|
||||
--partitions $partitions \
|
||||
--topic $topic
|
||||
then
|
||||
echo "Topic $topic created."
|
||||
else
|
||||
echo "Failed to create topic $topic."
|
||||
fi
|
||||
done
|
||||
|
||||
echo "All topics created."
|
||||
|
||||
-156
@@ -1,156 +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.
|
||||
|
||||
if ! command -v pv &> /dev/null
|
||||
then
|
||||
echo "pv not found, installing..."
|
||||
if [ -e /etc/debian_version ]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y pv
|
||||
elif [ -e /etc/redhat-release ]; then
|
||||
sudo yum install -y pv
|
||||
else
|
||||
echo "Unsupported OS, please install pv manually."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
readonly t_reset=$(tput sgr0)
|
||||
readonly green=$(tput bold; tput setaf 2)
|
||||
readonly yellow=$(tput bold; tput setaf 3)
|
||||
readonly blue=$(tput bold; tput setaf 6)
|
||||
readonly timeout=$(if [ "$(uname)" == "Darwin" ]; then echo "1"; else echo "0.1"; fi)
|
||||
readonly ipv6regex='(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))'
|
||||
|
||||
clear
|
||||
. $(dirname ${BASH_SOURCE})/lib/util.sh
|
||||
|
||||
openim::util::ensure-bash-version
|
||||
|
||||
trap 'openim::util::onCtrlC' INT
|
||||
|
||||
function openim::util::onCtrlC() {
|
||||
echo -e "\n${t_reset}Ctrl+C Press it. It's exiting openim make init..."
|
||||
exit 0
|
||||
}
|
||||
|
||||
openim::util::desc "========> Welcome to the OpenIM Demo"
|
||||
openim::util::desc "========> We'll help you get started with OpenIM quickly"
|
||||
openim::util::desc "========> Press Enter to continue...."
|
||||
openim::util::run "make advertise"
|
||||
clear
|
||||
|
||||
openim::util::desc "========> Initialize the project and generate configuration files"
|
||||
openim::util::run "make init"
|
||||
clear
|
||||
|
||||
# openim::util::desc "========> You can look git diff"
|
||||
# openim::util::run "git diff"
|
||||
# clear
|
||||
|
||||
openim::util::desc "You can learn a lot about automation using make help"
|
||||
openim::util::run "make help"
|
||||
clear
|
||||
|
||||
openim::util::desc "You can learn a lot about automation using make help-all"
|
||||
openim::util::run "make help-all"
|
||||
clear
|
||||
|
||||
openim::util::desc "First, let's verify and install some necessary tools"
|
||||
openim::util::run "make tools"
|
||||
clear
|
||||
|
||||
openim::util::desc "========> Start the basic openim docker components"
|
||||
openim::util::desc "========> You can use docker-compose ps to check the status of the container"
|
||||
openim::util::run "docker compose up -d"
|
||||
clear
|
||||
|
||||
openim::util::desc "========> Use make init-githooks Initialize git hooks "
|
||||
openim::util::run "make init-githooks"
|
||||
clear
|
||||
|
||||
openim::util::desc "The specification is pretty high, you need to be bound on your branch name, as well as commit messages"
|
||||
openim::util::run "git commit -a -s -m 'feta: commit demo against specification'"
|
||||
openim::util::run "# git commit -a -s -m 'feat: commit demo against specification' --amend"
|
||||
clear
|
||||
|
||||
openim::util::desc "How did we teach you how to build OpenIM"
|
||||
openim::util::desc "A full build startup check"
|
||||
openim::util::run "# make all"
|
||||
openim::util::desc "Build one OpenIM binary"
|
||||
openim::util::desc "BINS: openim-api openim-cmdutils openim-crontask openim-msggateway openim-msgtransfer openim-push openim-rpc changelog infra ncpu yamlfmt"
|
||||
openim::util::run "make build BINS=openim-api"
|
||||
openim::util::run "make build"
|
||||
|
||||
openim::util::desc "Build binaries for all platforms"
|
||||
openim::util::run "make multiarch -j BINS=openim-crontask PLATFORMS='linux_arm64 linux_amd64' "
|
||||
|
||||
openim::util::desc "If you wish to use dlv for debugging, either binary or process"
|
||||
openim::util::desc "You need to enable debug mode"
|
||||
openim::util::run "make build BINS=openim-cmdutils DEBUG=1"
|
||||
clear
|
||||
|
||||
openim::util::desc "Next, let's learn how to start the OpenIM service. For starting, we have two ways"
|
||||
openim::util::desc "The first is Background startup"
|
||||
openim::util::run "make start"
|
||||
openim::util::desc "The second way is through the Linux system way"
|
||||
openim::util::run "./scripts/install/install.sh --help"
|
||||
clear
|
||||
|
||||
openim::util::desc "Next, let's learn how to check the OpenIM service. For checking, we have two ways"
|
||||
openim::util::run "make check"
|
||||
clear
|
||||
|
||||
openim::util::desc "Next, let's learn how to stop the OpenIM service. For stopping, we have two ways"
|
||||
openim::util::run "make stop"
|
||||
clear
|
||||
|
||||
openim::util::desc "Run tidy to format and fix imports"
|
||||
openim::util::run "make tidy"
|
||||
clear
|
||||
|
||||
openim::util::desc "Vendor go.mod dependencies"
|
||||
openim::util::run "# make vendor"
|
||||
clear
|
||||
|
||||
openim::util::desc "Run unit tests"
|
||||
openim::util::run "# make test"
|
||||
clear
|
||||
|
||||
openim::util::desc "Run unit tests and get test coverage"
|
||||
openim::util::run "# make cover"
|
||||
clear
|
||||
|
||||
openim::util::desc "Check for updates to go.mod dependencies"
|
||||
openim::util::run "# make updates"
|
||||
clear
|
||||
|
||||
openim::util::desc "You can learn a lot about automation using make clean, remove all files that are created by building"
|
||||
openim::util::run "make clean"
|
||||
clear
|
||||
|
||||
openim::util::desc "Generate all necessary files"
|
||||
openim::util::run "make gen"
|
||||
clear
|
||||
|
||||
openim::util::desc "Verify the license headers for all files"
|
||||
openim::util::run "make verify-copyright"
|
||||
clear
|
||||
|
||||
openim::util::desc "Add copyright"
|
||||
openim::util::run "make add-copyright"
|
||||
clear
|
||||
|
||||
exit 0
|
||||
@@ -1,91 +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.
|
||||
|
||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${OPENIM_ROOT}/scripts/install/common.sh"
|
||||
|
||||
cd "$OPENIM_ROOT"
|
||||
|
||||
openim::util::check_docker_and_compose_versions
|
||||
|
||||
progress() {
|
||||
local _main_pid="$1"
|
||||
local _length=20
|
||||
local _ratio=1
|
||||
local _colors=("31" "32" "33" "34" "35" "36" "37")
|
||||
local _wave=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" "▇" "▆" "▅" "▄" "▃" "▂")
|
||||
|
||||
while pgrep -P "$_main_pid" &> /dev/null; do
|
||||
local _mark='>'
|
||||
local _progress_bar=
|
||||
for ((i = 1; i <= _length; i++)); do
|
||||
if ((i > _ratio)); then
|
||||
_mark='-'
|
||||
fi
|
||||
_progress_bar="${_progress_bar}${_mark}"
|
||||
done
|
||||
|
||||
local _color_idx=$((_ratio % ${#_colors[@]}))
|
||||
local _color_prefix="\033[${_colors[_color_idx]}m"
|
||||
local _reset_suffix="\033[0m"
|
||||
|
||||
local _wave_idx=$((_ratio % ${#_wave[@]}))
|
||||
local _wave_progress=${_wave[_wave_idx]}
|
||||
|
||||
printf "Progress: ${_color_prefix}${_progress_bar}${_reset_suffix} ${_wave_progress} Countdown: %2ds \r" "$_countdown"
|
||||
((_ratio++))
|
||||
((_ratio > _length)) && _ratio=1
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
|
||||
countdown() {
|
||||
local _duration="$1"
|
||||
|
||||
for ((i = _duration; i >= 1; i--)); do
|
||||
printf "\rCountdown: %2ds \r" "$i"
|
||||
sleep 1
|
||||
done
|
||||
printf "\rCountdown: %2ds \r" "$_duration"
|
||||
}
|
||||
|
||||
do_sth() {
|
||||
echo "++++++++++++++++++++++++"
|
||||
progress $$ &
|
||||
local _progress_pid=$!
|
||||
local _countdown=30
|
||||
|
||||
countdown "$_countdown" &
|
||||
local _countdown_pid=$!
|
||||
|
||||
sleep 30
|
||||
|
||||
kill "$_progress_pid" "$_countdown_pid"
|
||||
|
||||
"${SCRIPTS_ROOT}/check-all.sh"
|
||||
echo -e "${PURPLE_PREFIX}=========> Check docker-compose status ${COLOR_SUFFIX} \n"
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
do_sth &
|
||||
do_sth_pid=$(jobs -p | tail -1)
|
||||
|
||||
progress "${do_sth_pid}" &
|
||||
progress_pid=$(jobs -p | tail -1)
|
||||
|
||||
wait "${do_sth_pid}"
|
||||
printf "Progress: done \n"
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${OPENIM_ROOT}/scripts/install/common.sh"
|
||||
openim::log::info "\n# Use Docker to start all openim service"
|
||||
openim::log::info "\n# Use Docker to start all OpenIM service"
|
||||
trap 'openim::util::onCtrlC' INT
|
||||
"${OPENIM_ROOT}"/scripts/start-all.sh 2>&1 &
|
||||
tail -f ${DOCKER_LOG_FILE}
|
||||
|
||||
+47
-41
@@ -13,66 +13,72 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
DEFAULT_DIRS=(
|
||||
"pkg"
|
||||
"internal/pkg"
|
||||
)
|
||||
BASE_URL="github.com/openimsdk/open-im-server"
|
||||
#!/bin/bash
|
||||
|
||||
DEFAULT_DIRS=("pkg")
|
||||
BASE_URL="github.com/openimsdk/open-im-server/v3"
|
||||
REMOVE_DOC=false
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo
|
||||
echo "This script iterates over directories and generates doc.go if necessary."
|
||||
echo "By default, it processes 'pkg' and 'internal/pkg' directories."
|
||||
echo "This script iterates over directories. By default, it generates doc.go files for 'pkg' and 'internal/pkg'."
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -d DIRS, --dirs DIRS Specify the directories to be processed, separated by commas. E.g., 'pkg,internal/pkg'."
|
||||
echo " -u URL, --url URL Set the base URL for the import path. Default is '$BASE_URL'."
|
||||
echo " -h, --help Show this help message."
|
||||
echo " -d DIRS, --dirs DIRS Specify directories to process, separated by commas (e.g., 'pkg,internal/pkg')."
|
||||
echo " -u URL, --url URL Set the base URL for the import path. Default is '$BASE_URL'."
|
||||
echo " -r, --remove Remove all doc.go files in the specified directories."
|
||||
echo " -h, --help Show this help message."
|
||||
echo
|
||||
}
|
||||
|
||||
process_dir() {
|
||||
local dir=$1
|
||||
local base_url=$2
|
||||
|
||||
for d in $(find $dir -type d); do
|
||||
if [ ! -f $d/doc.go ]; then
|
||||
if ls $d/*.go > /dev/null 2>&1; then
|
||||
echo $d/doc.go
|
||||
echo "package $(basename $d) // import \"$base_url/$d\"" > $d/doc.go
|
||||
local dir="$1"
|
||||
local base_url="$2"
|
||||
local remove_doc="$3"
|
||||
|
||||
find "$dir" -type d | while read -r d; do
|
||||
if [ "$remove_doc" = true ]; then
|
||||
if [ -f "$d/doc.go" ]; then
|
||||
echo "Removing $d/doc.go"
|
||||
rm -f "$d/doc.go"
|
||||
fi
|
||||
else
|
||||
if [ ! -f "$d/doc.go" ] && ls "$d/"*.go &>/dev/null; then
|
||||
echo "Creating $d/doc.go"
|
||||
echo "package $(basename "$d") // import \"$base_url/$(echo "$d" | sed "s|^\./||")\"" >"$d/doc.go"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
case "$1" in
|
||||
-d|--dirs)
|
||||
IFS=',' read -ra DIRS <<< "$2"
|
||||
shift # shift past argument
|
||||
shift # shift past value
|
||||
;;
|
||||
-u|--url)
|
||||
BASE_URL="$2"
|
||||
shift # shift past argument
|
||||
shift # shift past value
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
IFS=',' read -ra DIRS <<< "$2"
|
||||
shift 2
|
||||
;;
|
||||
-u|--url)
|
||||
BASE_URL="$2"
|
||||
shift 2
|
||||
;;
|
||||
-r|--remove)
|
||||
REMOVE_DOC=true
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
DIRS=${DIRS:-${DEFAULT_DIRS[@]}}
|
||||
DIRS=(${DIRS:-"${DEFAULT_DIRS[@]}"})
|
||||
|
||||
for dir in "${DIRS[@]}"; do
|
||||
process_dir $dir $BASE_URL
|
||||
process_dir "$dir" "$BASE_URL" "$REMOVE_DOC"
|
||||
done
|
||||
|
||||
@@ -65,6 +65,8 @@ GENERATE_EXAMPLES=false
|
||||
CLEAN_CONFIG=false
|
||||
CLEAN_EXAMPLES=false
|
||||
|
||||
FILES_PROCESSED=false
|
||||
|
||||
# Function to display help information
|
||||
show_help() {
|
||||
echo "Usage: $(basename "$0") [options]"
|
||||
@@ -126,7 +128,7 @@ process_file() {
|
||||
if [[ "${FORCE_OVERWRITE}" == true ]]; then
|
||||
openim::log::info "Force overwriting ${output_file}."
|
||||
elif [[ "${SKIP_EXISTING}" == true ]]; then
|
||||
openim::log::info "Skipping generation of ${output_file} as it already exists."
|
||||
#openim::log::info "Skipping generation of ${output_file} as it already exists."
|
||||
return
|
||||
else
|
||||
echo -n "File ${output_file} already exists. Overwrite? (Y/N): "
|
||||
@@ -173,8 +175,7 @@ process_file() {
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
sleep 0.5
|
||||
FILES_PROCESSED=true
|
||||
}
|
||||
|
||||
clean_config_files() {
|
||||
@@ -259,4 +260,6 @@ if [[ "${GENERATE_EXAMPLES}" == true ]] && [[ "${CLEAN_EXAMPLES}" == false ]]; t
|
||||
generate_example_files
|
||||
fi
|
||||
|
||||
openim::log::success "Configuration and example files operation complete!"
|
||||
if [[ "${FILES_PROCESSED}" == true ]]; then
|
||||
openim::log::success "Configuration and example files operation complete!"
|
||||
fi
|
||||
|
||||
@@ -89,7 +89,7 @@ function openim::api::start_service() {
|
||||
echo "Starting service with command: $cmd"
|
||||
|
||||
#nohup $cmd >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 &
|
||||
if [ $? -ne 0 ]; then
|
||||
openim::log::error_exit "Failed to start ${binary_name} on port ${service_port}."
|
||||
return 1
|
||||
|
||||
@@ -53,7 +53,7 @@ function openim::crontask::start() {
|
||||
openim::log::status "start cron_task process, path: ${OPENIM_CRONTASK_BINARY}"
|
||||
#nohup ${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
|
||||
cmd="${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG}"
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 &
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ function openim::msggateway::start() {
|
||||
PROMETHEUS_PORT_OPTION="--prometheus_port ${MSG_GATEWAY_PROM_PORTS_ARRAY[$i]}"
|
||||
fi
|
||||
cmd="${OPENIM_MSGGATEWAY_BINARY} --port ${OPENIM_MSGGATEWAY_PORTS_ARRAY[$i]} --ws_port ${OPENIM_WS_PORTS_ARRAY[$i]} $PROMETHEUS_PORT_OPTION -c ${OPENIM_MSGGATEWAY_CONFIG}"
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 &
|
||||
# nohup ${OPENIM_MSGGATEWAY_BINARY} --port ${OPENIM_MSGGATEWAY_PORTS_ARRAY[$i]} --ws_port ${OPENIM_WS_PORTS_ARRAY[$i]} $PROMETHEUS_PORT_OPTION -c ${OPENIM_MSGGATEWAY_CONFIG} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
|
||||
|
||||
done
|
||||
|
||||
@@ -58,7 +58,8 @@ function openim::msgtransfer::start() {
|
||||
PROMETHEUS_PORT_OPTION="--prometheus_port ${PROMETHEUS_MSG_TRANSFER_PORT}"
|
||||
fi
|
||||
cmd="${OPENIM_MSGTRANSFER_BINARY} ${PROMETHEUS_PORT_OPTION} -c ${OPENIM_MSGTRANSFER_CONFIG} -n ${i}"
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
|
||||
#nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 &
|
||||
#nohup ${OPENIM_MSGTRANSFER_BINARY} ${PROMETHEUS_PORT_OPTION} -c ${OPENIM_MSGTRANSFER_CONFIG} -n ${i} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
|
||||
done
|
||||
return 0
|
||||
@@ -82,7 +83,7 @@ function openim::msgtransfer::check() {
|
||||
fi
|
||||
done
|
||||
else
|
||||
openim::log::error "Expected $OPENIM_MSGGATEWAY_NUM openim msgtransfer processes, but found $NUM_PROCESSES msgtransfer processes."
|
||||
openim::log::error "Expected $OPENIM_MSGGATEWAY_NUM OpenIM msgtransfer processes, but found $NUM_PROCESSES msgtransfer processes running"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
|
||||
@@ -72,7 +72,8 @@ function openim::push::start() {
|
||||
for (( i=0; i<${#OPENIM_PUSH_PORTS_ARRAY[@]}; i++ )); do
|
||||
openim::log::info "start push process, port: ${OPENIM_PUSH_PORTS_ARRAY[$i]}, prometheus port: ${PUSH_PROM_PORTS_ARRAY[$i]}"
|
||||
cmd="${OPENIM_PUSH_BINARY} --port ${OPENIM_PUSH_PORTS_ARRAY[$i]} -c ${OPENIM_PUSH_CONFIG} --prometheus_port ${PUSH_PROM_PORTS_ARRAY[$i]}"
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
|
||||
#nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 &
|
||||
#nohup ${OPENIM_PUSH_BINARY} --port ${OPENIM_PUSH_PORTS_ARRAY[$i]} -c ${OPENIM_PUSH_CONFIG} --prometheus_port ${PUSH_PROM_PORTS_ARRAY[$i]} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
|
||||
done
|
||||
return 0
|
||||
|
||||
@@ -166,7 +166,8 @@ function openim::rpc::start_service() {
|
||||
cmd="${cmd} --prometheus_port ${prometheus_port}"
|
||||
fi
|
||||
#nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
|
||||
#nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
|
||||
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 &
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -83,67 +83,65 @@ function openim::tools::start_service() {
|
||||
local prometheus_port="$4"
|
||||
|
||||
local cmd="${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${binary_name}"
|
||||
openim::log::info "Starting PATH: ${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${binary_name}..."
|
||||
#openim::log::info "Starting PATH: ${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${binary_name}..."
|
||||
|
||||
if [ -n "${config}" ]; then
|
||||
printf "Specifying config: %s\n" "${config}"
|
||||
# printf "Specifying config: %s\n" "${config}"
|
||||
cmd="${cmd} -c ${config}/config.yaml"
|
||||
fi
|
||||
|
||||
if [ -n "${service_port}" ]; then
|
||||
printf "Specifying service port: %s\n" "${service_port}"
|
||||
#printf "Specifying service port: %s\n" "${service_port}"
|
||||
cmd="${cmd} --port ${service_port}"
|
||||
fi
|
||||
|
||||
if [ -n "${prometheus_port}" ]; then
|
||||
printf "Specifying prometheus port: %s\n" "${prometheus_port}"
|
||||
#printf "Specifying prometheus port: %s\n" "${prometheus_port}"
|
||||
cmd="${cmd} --prometheus_port ${prometheus_port}"
|
||||
fi
|
||||
openim::log::status "Starting binary ${binary_name}..."
|
||||
#openim::log::status "Starting binary ${binary_name}..."
|
||||
|
||||
|
||||
|
||||
${cmd}
|
||||
|
||||
# openim::log::info "cmd: $cmd"
|
||||
${cmd}
|
||||
|
||||
|
||||
local status=$?
|
||||
|
||||
if [ $status -eq 0 ]; then
|
||||
openim::log::info "Service ${binary_name} started successfully."
|
||||
return 0
|
||||
else
|
||||
openim::log::error "Failed to start service ${binary_name}."
|
||||
return 1
|
||||
fi
|
||||
if [ $status -eq 0 ]; then
|
||||
openim::log::colorless "Service ${binary_name} started successfully."
|
||||
return 0
|
||||
else
|
||||
openim::log::error "Failed to start service ${binary_name}."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function openim::tools::start() {
|
||||
openim::log::info "Starting OpenIM Tools..."
|
||||
for tool in "${OPENIM_TOOLS_NAME_LISTARIES[@]}"; do
|
||||
openim::log::info "Starting tool ${tool}..."
|
||||
openim::log::colorless "Starting tool ${tool}..."
|
||||
# openim::tools::start_service ${tool}
|
||||
sleep 0.2
|
||||
#sleep 0.2
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
function openim::tools::pre-start() {
|
||||
openim::log::info "Preparing to start OpenIM Tools..."
|
||||
#openim::log::info "Preparing to start OpenIM Tools..."
|
||||
for tool in "${OPENIM_TOOLS_PRE_START_NAME_LISTARIES[@]}"; do
|
||||
openim::log::info "Starting tool ${tool}..."
|
||||
openim::log::colorless "Starting tool: ${tool}"
|
||||
if ! openim::tools::start_service ${tool} ${OPNEIM_CONFIG}; then
|
||||
openim::log::error "Failed to start ${tool}, aborting..."
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
openim::log::info "All tools started successfully."
|
||||
#openim::log::info "All tools started successfully."
|
||||
}
|
||||
|
||||
function openim::tools::post-start() {
|
||||
openim::log::info "Post-start actions for OpenIM Tools..."
|
||||
#openim::log::info "Post-start actions for OpenIM Tools..."
|
||||
for tool in "${OPENIM_TOOLS_POST_START_NAME_LISTARIES[@]}"; do
|
||||
openim::log::info "Starting tool ${tool}..."
|
||||
openim::log::colorless "Starting tool: ${tool}"
|
||||
openim::tools::start_service ${tool}
|
||||
done
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ openim::golang::start_script_list() {
|
||||
openim-msgtransfer.sh
|
||||
openim-msggateway.sh
|
||||
openim-crontask.sh
|
||||
openim-tools.sh
|
||||
#openim-tools.sh
|
||||
)
|
||||
local result=()
|
||||
for target in "${targets[@]}"; do
|
||||
@@ -181,7 +181,7 @@ openim::golang::check_openim_binaries() {
|
||||
done
|
||||
return 1
|
||||
else
|
||||
echo "All binaries have been installed in ${OPENIM_OUTPUT_HOSTBIN}。"
|
||||
echo -e "All binaries have been installed in: \n${OPENIM_OUTPUT_HOSTBIN}\n${OPENIM_OUTPUT_HOSTBIN_TOOLS}"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
@@ -317,8 +317,6 @@ readonly OPENIM_CLIENT_TARGETS=(
|
||||
imctl
|
||||
infra
|
||||
ncpu
|
||||
openim-web
|
||||
up35
|
||||
versionchecker
|
||||
yamlfmt
|
||||
)
|
||||
|
||||
+25
-5
@@ -210,16 +210,26 @@ openim::log::status() {
|
||||
if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]")
|
||||
echo_log "${timestamp} ${1}"
|
||||
|
||||
local COLOR_BLUE="\033[0;34m"
|
||||
local COLOR_RESET="\033[0m"
|
||||
|
||||
local timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]")
|
||||
|
||||
echo_log() {
|
||||
echo -e "$@"
|
||||
}
|
||||
|
||||
|
||||
echo_log "${COLOR_BLUE}${timestamp} ${1}${COLOR_RESET}"
|
||||
shift
|
||||
for message; do
|
||||
echo_log " ${message}"
|
||||
echo_log "${COLOR_BLUE}${message}${COLOR_RESET}"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
openim::log::success() {
|
||||
local V="${V:-0}"
|
||||
if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
|
||||
@@ -232,7 +242,6 @@ openim::log::success() {
|
||||
|
||||
|
||||
|
||||
|
||||
function openim::log::test_log() {
|
||||
echo_log "test log"
|
||||
openim::log::info "openim::log::info"
|
||||
@@ -249,3 +258,14 @@ function openim::log::print_blue() {
|
||||
echo -e "\033[0;36m$1\033[0m"
|
||||
}
|
||||
|
||||
|
||||
openim::log::colorless() {
|
||||
local V="${V:-0}"
|
||||
if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
|
||||
return
|
||||
fi
|
||||
timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]")
|
||||
echo_log -e "${timestamp} ${1} "
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ function openim::release::package_client_tarballs() {
|
||||
|
||||
local client_bins=("${OPENIM_CLIENT_BINARIES[@]}")
|
||||
|
||||
# client_bins: changelog component imctl infra ncpu openim-web up35 versionchecker yamlfmt
|
||||
# client_bins: changelog component imctl infra ncpu versionchecker yamlfmt
|
||||
# Copy client binclient_bins:aries
|
||||
openim::log::info " Copy client binaries: ${client_bins[@]/#/${LOCAL_OUTPUT_BINTOOLSPATH}/${platform}/}"
|
||||
openim::log::info " Copy client binaries to: ${release_stage}/client/bin"
|
||||
|
||||
+62
-19
@@ -360,8 +360,8 @@ openim::util::check_ports() {
|
||||
|
||||
# If any of the processes is not running, return a status of 1.
|
||||
if [[ ${#not_started[@]} -ne 0 ]]; then
|
||||
openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}"
|
||||
openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}"
|
||||
#openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}"
|
||||
#openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}"
|
||||
cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}'
|
||||
return 1
|
||||
else
|
||||
@@ -446,8 +446,8 @@ openim::util::check_process_names() {
|
||||
|
||||
# Return status
|
||||
if [[ ${#not_started[@]} -ne 0 ]]; then
|
||||
openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}"
|
||||
openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}"
|
||||
#openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}"
|
||||
#openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}"
|
||||
cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}'
|
||||
return 1
|
||||
else
|
||||
@@ -599,33 +599,36 @@ openim::util::stop_services_with_name() {
|
||||
# An array to collect information about processes that were stopped.
|
||||
local stopped=()
|
||||
|
||||
echo "Stopping services with names: $*"
|
||||
# Iterate over each given service name.
|
||||
for server_name in "$@"; do
|
||||
# Use the `pgrep` command to find process IDs related to the given service name.
|
||||
local pids=$(pgrep -f "$server_name")
|
||||
|
||||
# If no process was found with the name, add it to the not_stopped list
|
||||
if [[ -z $pids ]]; then
|
||||
not_stopped+=("$server_name")
|
||||
continue
|
||||
fi
|
||||
local stopped_this_time=false
|
||||
for pid in $pids; do
|
||||
for pid in $pids; do
|
||||
|
||||
# Exclude the PID of the current script
|
||||
if [[ "$pid" == "$$" ]]; then
|
||||
continue
|
||||
fi
|
||||
# Exclude the PID of the current script
|
||||
if [[ "$pid" == "$$" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# If there's a Process ID, it means the service with the name is running.
|
||||
if [[ -n $pid ]]; then
|
||||
# Print the binary path for the PID
|
||||
binary_path=$(readlink -f /proc/$pid/exe)
|
||||
openim::log::colorless "stop PID $pid full path: $binary_path"
|
||||
|
||||
# Try to stop the service by killing its process.
|
||||
if kill -15 $pid 2>/dev/null; then
|
||||
stopped_this_time=true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# 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 -15 $pid 2>/dev/null; then
|
||||
stopped_this_time=true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if $stopped_this_time; then
|
||||
stopped+=("$server_name")
|
||||
@@ -2848,6 +2851,46 @@ function openim::util::check_process_names_for_stop() {
|
||||
|
||||
|
||||
|
||||
function openim::util::find_process_ports() {
|
||||
local process_path="$1"
|
||||
if [[ -z "$process_path" ]]; then
|
||||
echo "Usage: find_process_ports /path/to/process"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local protocol_ports=""
|
||||
while read -r line; do
|
||||
local port_protocol=($line)
|
||||
local port=${port_protocol[0]##*:}
|
||||
local protocol=${port_protocol[1]}
|
||||
protocol_ports="${protocol_ports}${protocol} ${port}, "
|
||||
|
||||
done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}')
|
||||
|
||||
protocol_ports=${protocol_ports%, }
|
||||
|
||||
if [[ -z "$protocol_ports" ]]; then
|
||||
openim::log::colorless "$process_path is not listening on any ports"
|
||||
else
|
||||
openim::log::colorless "$process_path is listening on protocol & port: $protocol_ports"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function openim::util::find_ports_for_all_services() {
|
||||
local services=("$@")
|
||||
for service in "${services[@]}"; do
|
||||
openim::util::find_process_ports "$service"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if [[ "$*" =~ openim::util:: ]];then
|
||||
eval $*
|
||||
fi
|
||||
|
||||
@@ -19,8 +19,5 @@
|
||||
# Usage: `scripts/list-feature-tests.sh`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
grep "\[Feature:\w+\]" "${OPENIM_ROOT}"/test/e2e/**/*.go -Eoh | LC_ALL=C sort -u
|
||||
@@ -88,11 +88,6 @@ gen.docgo.check: gen.docgo.doc
|
||||
gen.docgo.add:
|
||||
@git ls-files --others '*/doc.go' | $(XARGS) -- git add
|
||||
|
||||
## gen.docgo: Generate missing doc.go for go packages ✨
|
||||
.PHONY: gen.defaultconfigs
|
||||
gen.defaultconfigs:
|
||||
@${ROOT_DIR}/scripts/gen_default_config.sh
|
||||
|
||||
## gen.docgo: Generate missing doc.go for go packages ✨
|
||||
.PHONY: gen.clean
|
||||
gen.clean:
|
||||
@@ -101,5 +96,5 @@ gen.clean:
|
||||
|
||||
## gen.help: show help for gen
|
||||
.PHONY: gen.help
|
||||
gen.help: scripts/make-rules/gen.mk
|
||||
gen.help: scripts/make-rules/gen.m
|
||||
$(call smallhelp)
|
||||
@@ -104,25 +104,25 @@ go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BIN
|
||||
## go.start: Start openim
|
||||
.PHONY: go.start
|
||||
go.start:
|
||||
@echo "===========> Starting openim"
|
||||
@echo "=========================> Starting OpenIM <========================="
|
||||
@$(ROOT_DIR)/scripts/start-all.sh
|
||||
|
||||
## go.stop: Stop openim
|
||||
.PHONY: go.stop
|
||||
go.stop:
|
||||
@echo "===========> Stopping openim"
|
||||
@echo "=========================> Stopping OpenIM <========================="
|
||||
@$(ROOT_DIR)/scripts/stop-all.sh
|
||||
|
||||
## go.check: Check openim
|
||||
.PHONY: go.check
|
||||
go.check:
|
||||
@echo "===========> Checking openim"
|
||||
@echo "=========================> Checking OpenIM <========================="
|
||||
@$(ROOT_DIR)/scripts/check-all.sh
|
||||
|
||||
## go.check-component: Check openim component
|
||||
.PHONY: go.check-component
|
||||
go.check-component:
|
||||
@echo "===========> Checking openim component"
|
||||
@echo "=========================> Checking OpenIM component <========================="
|
||||
@$(ROOT_DIR)/scripts/install/openim-tools.sh openim::tools::pre-start
|
||||
|
||||
## go.versionchecker: Design, detect some environment variables and versions
|
||||
|
||||
+27
-9
@@ -12,19 +12,37 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -e
|
||||
|
||||
mongosh <<EOF
|
||||
use admin
|
||||
db.auth('$MONGO_INITDB_ROOT_USERNAME', '$MONGO_INITDB_ROOT_PASSWORD')
|
||||
var rootUsername = '$MONGO_INITDB_ROOT_USERNAME';
|
||||
var rootPassword = '$MONGO_INITDB_ROOT_PASSWORD';
|
||||
var authResult = db.auth(rootUsername, rootPassword);
|
||||
if (authResult) {
|
||||
print('Authentication successful for root user: ' + rootUsername);
|
||||
} else {
|
||||
print('Authentication failed for root user: ' + rootUsername + ' with password: ' + rootPassword);
|
||||
quit(1);
|
||||
}
|
||||
|
||||
db = db.getSiblingDB('$MONGO_INITDB_DATABASE')
|
||||
db.createUser({
|
||||
user: "$MONGO_OPENIM_USERNAME",
|
||||
pwd: "$MONGO_OPENIM_PASSWORD",
|
||||
var dbName = '$MONGO_INITDB_DATABASE';
|
||||
db = db.getSiblingDB(dbName);
|
||||
var openimUsername = '$MONGO_OPENIM_USERNAME';
|
||||
var openimPassword = '$MONGO_OPENIM_PASSWORD';
|
||||
var createUserResult = db.createUser({
|
||||
user: openimUsername,
|
||||
pwd: openimPassword,
|
||||
roles: [
|
||||
// Assign appropriate roles here
|
||||
{ role: 'readWrite', db: '$MONGO_INITDB_DATABASE' }
|
||||
{ role: 'readWrite', db: dbName }
|
||||
]
|
||||
});
|
||||
|
||||
if (createUserResult.ok == 1) {
|
||||
print('User creation successful. User: ' + openimUsername + ', Database: ' + dbName);
|
||||
} else {
|
||||
print('User creation failed for user: ' + openimUsername + ' in database: ' + dbName);
|
||||
quit(1);
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
|
||||
+17
-37
@@ -16,18 +16,9 @@
|
||||
#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.
|
||||
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${OPENIM_ROOT}/scripts/install/common.sh"
|
||||
|
||||
|
||||
|
||||
# Function to execute the scripts.
|
||||
function execute_start_scripts() {
|
||||
for script_path in "${OPENIM_SERVER_SCRIPT_START_LIST[@]}"; do
|
||||
@@ -42,8 +33,7 @@ function execute_start_scripts() {
|
||||
|
||||
# Check if the script file exists and is executable.
|
||||
if [[ -x "$script_path" ]]; then
|
||||
openim::log::print_blue "Starting script: ${script_path##*/}" # Log the script name.
|
||||
|
||||
openim::log::colorless "Starting script: ${script_path##*/}" # Log the script name.
|
||||
# Execute the script with the constructed argument.
|
||||
result=$("$script_path" "$arg")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
@@ -59,41 +49,31 @@ function execute_start_scripts() {
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if openim::util::is_running_in_container; then
|
||||
exec >> ${DOCKER_LOG_FILE} 2>&1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
openim::golang::check_openim_binaries
|
||||
if [[ $? -ne 0 ]]; then
|
||||
openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries."
|
||||
"${OPENIM_ROOT}"/scripts/build-all-service.sh
|
||||
fi
|
||||
|
||||
|
||||
"${OPENIM_ROOT}"/scripts/init-config.sh --skip
|
||||
|
||||
#openim::log::print_blue "Execute the following script in sequence: ${OPENIM_SERVER_SCRIPTARIES[@]}"
|
||||
|
||||
|
||||
# TODO Prelaunch tools, simple for now, can abstract functions later
|
||||
TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh
|
||||
|
||||
openim::log::print_blue "\n## Pre Starting OpenIM services"
|
||||
openim::log::status "Start the pre-start tools:"
|
||||
|
||||
# if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then
|
||||
# openim::log::error "Start the pre-start tools, aborting!"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
|
||||
if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then
|
||||
openim::log::error "Pre Starting OpenIM services failed, aborting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
openim::log::print_blue "Pre Starting OpenIM services processed successfully"
|
||||
openim::log::colorless "pre-start has been successfully completed!"
|
||||
|
||||
result=$("${OPENIM_ROOT}"/scripts/stop-all.sh)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
@@ -102,28 +82,28 @@ if [[ $? -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
openim::log::status "\n## Starting openim scripts: "
|
||||
openim::log::status "Start the OpenIM startup scripts: "
|
||||
execute_start_scripts
|
||||
openim::log::status "OpenIM startup scripts have been successfully completed!"
|
||||
|
||||
sleep 2
|
||||
|
||||
result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
openim::log::error "The program may fail to start.\n $result"
|
||||
openim::log::error "The OpenIM services may fail to start.\n $result"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]})
|
||||
if [[ $? -ne 0 ]]; then
|
||||
openim::log::error "The program may fail to start.\n $result"
|
||||
openim::log::error "The OpenIM services may fail to start.\n $result"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openim::log::status "Start the post-start tools:"
|
||||
# ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start
|
||||
openim::log::status "post-start has been successfully completed!"
|
||||
openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}
|
||||
openim::util::find_ports_for_all_services ${OPENIM_MSGTRANSFER_BINARY[@]}
|
||||
|
||||
openim::log::info "\n## Post Starting openim services"
|
||||
${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start
|
||||
|
||||
openim::log::success "All openim services have been successfully started!"
|
||||
openim::log::success "All OpenIM services have been successfully started!"
|
||||
Reference in New Issue
Block a user