Skip to content

Commit

Permalink
fix bug: read port information from the configuration file.
Browse files Browse the repository at this point in the history
Signed-off-by: skiffer-git <[email protected]>
  • Loading branch information
skiffer-git committed Jan 4, 2024
1 parent 2a3af8a commit f9773da
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions scripts/check_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,41 @@ service_port_name=(
openImChatPort
)
sleep 10
switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}')
for i in ${service_port_name[*]}; do


# Define the path to the configuration YAML file
config_yaml="$OPENIM_ROOT/config/config.yaml" # Replace with the actual path to your YAML file


# Function to extract a value from the YAML file and remove any leading/trailing whitespace
extract_yaml_value() {
local key=$1
grep -oP "${key}: \[\s*\K[^\]]+" "$config_yaml" | xargs
}

# Extract port numbers from the YAML configuration
openImChatApiPort=$(extract_yaml_value 'openImChatApiPort')
openImAdminApiPort=$(extract_yaml_value 'openImAdminApiPort')
openImAdminPort=$(extract_yaml_value 'openImAdminPort')
openImChatPort=$(extract_yaml_value 'openImChatPort')

for i in "${service_port_name[@]}"; do
case $i in
"openImChatApiPort")
new_service_name="chat-api"
new_service_port="10008"
new_service_port=$openImChatApiPort
;;
"openImAdminApiPort")
new_service_name="admin-rpc"
new_service_port="30200"
new_service_name="admin-api"
new_service_port=$openImAdminApiPort
;;
"openImAdminPort")
new_service_name="chat-rpc"
new_service_port="30300"
new_service_name="admin-rpc"
new_service_port=$openImAdminPort
;;
"openImChatPort")
new_service_name="admin-api"
new_service_port="10009"
new_service_name="chat-rpc"
new_service_port=$openImChatPort
;;
*)
echo "Invalid service name: $i"
Expand All @@ -78,4 +95,5 @@ for i in ${service_port_name[*]}; do
else
echo -e "${new_service_port}${GREEN_PREFIX} port has been listening, belongs service is ${i}${COLOR_SUFFIX}"
fi
done
done

0 comments on commit f9773da

Please sign in to comment.