Skip to content

Commit bed112d

Browse files
authored
Update check-all.sh (openimsdk#1643)
1 parent a7138cb commit bed112d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: scripts/check-all.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ OPENIM_VERBOSE=4
3030

3131
openim::log::info "\n# Begin to check all openim service"
3232

33+
# Elegant printing function
3334
# Elegant printing function
3435
print_services_and_ports() {
35-
local -n service_names=$1
36-
local -n service_ports=$2
36+
local service_names=("$@")
37+
local half_length=$((${#service_names[@]} / 2))
38+
local service_ports=("${service_names[@]:half_length}")
3739

3840
echo "+-------------------------+----------+"
3941
echo "| Service Name | Port |"
4042
echo "+-------------------------+----------+"
4143

42-
for index in "${!service_names[@]}"; do
44+
for ((index=0; index < half_length; index++)); do
4345
printf "| %-23s | %-8s |\n" "${service_names[$index]}" "${service_ports[$index]}"
4446
done
4547

@@ -50,11 +52,10 @@ print_services_and_ports() {
5052
# Similarly for OPENIM_DEPENDENCY_TARGETS and OPENIM_DEPENDENCY_PORT_TARGETS
5153

5254
# Print out services and their ports
53-
print_services_and_ports OPENIM_SERVER_NAME_TARGETS OPENIM_SERVER_PORT_TARGETS
55+
print_services_and_ports "${OPENIM_SERVER_NAME_TARGETS[@]}" "${OPENIM_SERVER_PORT_TARGETS[@]}"
5456

5557
# Print out dependencies and their ports
56-
print_services_and_ports OPENIM_DEPENDENCY_TARGETS OPENIM_DEPENDENCY_PORT_TARGETS
57-
58+
print_services_and_ports "${OPENIM_DEPENDENCY_TARGETS[@]}" "${OPENIM_DEPENDENCY_PORT_TARGETS[@]}"
5859

5960
# OpenIM check
6061
echo "++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}"
@@ -91,4 +92,4 @@ else
9192
echo "++++ Check all openim service ports successfully !"
9293
fi
9394

94-
set -e
95+
set -e

0 commit comments

Comments
 (0)