mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 11:52:10 +08:00
Script Refactoring
This commit is contained in:
parent
cb75f2e9dc
commit
1600d1d2c1
@ -32,6 +32,29 @@ start_binaries() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
start_tools() {
|
||||||
|
# Assume tool_binaries=("ncpu" "infra")
|
||||||
|
for binary in "${tool_binaries[@]}"; do
|
||||||
|
local bin_full_path=$(get_tool_full_path "$binary")
|
||||||
|
# Assuming get_tool_full_path defines full path for each tool
|
||||||
|
cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG")
|
||||||
|
echo "Starting ${cmd[@]}"
|
||||||
|
"${cmd[@]}"
|
||||||
|
ret_val=$?
|
||||||
|
if [ $ret_val -eq 0 ]; then
|
||||||
|
echo "Started $bin_full_path successfully."
|
||||||
|
else
|
||||||
|
echo "Failed to start $bin_full_path with exit code $ret_val."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#kill二进制全路径对应的进程
|
#kill二进制全路径对应的进程
|
||||||
kill_exist_binaries(){
|
kill_exist_binaries(){
|
||||||
for binary in "${!binaries[@]}"; do
|
for binary in "${!binaries[@]}"; do
|
||||||
|
|||||||
@ -7,3 +7,5 @@ declare -A binaries=(
|
|||||||
[openim-no-port]=2
|
[openim-no-port]=2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
tool_binaries=("ncpu" "infra")
|
||||||
|
|||||||
@ -14,3 +14,8 @@ get_bin_full_path() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
get_tool_full_path() {
|
||||||
|
local tool_name="$1"
|
||||||
|
local tool_full_path="${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${bin_name}"
|
||||||
|
echo ${tool_full_path}
|
||||||
|
}
|
||||||
|
|||||||
@ -12,6 +12,17 @@ source "$OPENIM_SCRIPTS/bricks.sh"
|
|||||||
# Main function to start binaries
|
# Main function to start binaries
|
||||||
|
|
||||||
|
|
||||||
|
result=$(start_tools)
|
||||||
|
ret_val=$?
|
||||||
|
|
||||||
|
|
||||||
|
if [ $ret_val -ne 0 ]; then
|
||||||
|
echo "tools start failed, abort start"
|
||||||
|
echo "$result"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
kill_exist_binaries
|
kill_exist_binaries
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user