Skip to content

Commit

Permalink
fix(release-v1.5): fix release-v1.5 scritps bug support mac deployment (
Browse files Browse the repository at this point in the history
  • Loading branch information
cubxxw authored Jan 29, 2024
1 parent 53be77b commit 66082d9
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 42 deletions.
4 changes: 2 additions & 2 deletions scripts/admin_rpc_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sleep 1
cd ${push_binary_root}

for ((i = 0; i < ${#rpc_ports[@]}; i++)); do
nohup ./${push_name} -port ${rpc_ports[$i]} -prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 &
nohup ./${push_name} -port ${rpc_ports[$i]} -prometheus_port ${prome_ports[$i]} >>../logs/openim_$(date '+%Y%m%d').log 2>&1 &
done

sleep 3
Expand All @@ -61,5 +61,5 @@ if [ $check -ge 1 ]; then
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
else
echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openim_$(date '+%Y%m%d').log"${COLOR_SUFFIX}
fi
6 changes: 5 additions & 1 deletion scripts/build_all_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ echo -e "${BOLD_PREFIX}_________________________________________________________


bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
logs_dir="$OPENIM_ROOT/_output/logs"

if [ ! -d $logs_dir ]; then
mkdir -p $logs_dir
fi

echo "==> bin_dir=$bin_dir"
echo "==> logs_dir=$logs_dir"
Expand Down
87 changes: 54 additions & 33 deletions scripts/check_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi
mkdir -p ${SCRIPTS_ROOT}/../logs
# 如果没有设置 PRINT_SCREEN 标记,那么进行日志重定向
if [ -z "$PRINT_SCREEN" ]; then
exec >> ${SCRIPTS_ROOT}/../logs/openIM.log 2>&1
exec >> ${SCRIPTS_ROOT}/../logs/openim_$(date '+%Y%m%d').log 2>&1
fi

#Include shell font styles and some basic information
Expand All @@ -50,50 +50,71 @@ sleep 10
# 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=$openImChatApiPort
# Detect the operating system
case "$(uname)" in
"Linux")
# Use grep with Perl-compatible regex for Linux
grep -oP "${key}: \[\s*\K[^\]]+" "$config_yaml" | xargs
;;
"openImAdminApiPort")
new_service_name="admin-api"
new_service_port=$openImAdminApiPort
"Darwin")
# Use sed for macOS
sed -nE "/${key}: \[ */{s///; s/\].*//; p;}" "$config_yaml" | tr -d '[]' | xargs
;;
"openImAdminPort")
new_service_name="admin-rpc"
new_service_port=$openImAdminPort
*)
echo "Unsupported operating system"
exit 1
;;
"openImChatPort")
new_service_name="chat-rpc"
new_service_port=$openImChatPort
esac
}

# Extract port numbers from the YAML configuration
declare -A service_ports=(
["openImChatApiPort"]="chat-api"
["openImAdminApiPort"]="admin-api"
["openImAdminPort"]="admin-rpc"
["openImChatPort"]="chat-rpc"
)

for i in "${!service_ports[@]}"; do
service_port=$(extract_yaml_value "$i")
new_service_name=${service_ports[$i]}

# Check for empty port value
if [ -z "$service_port" ]; then
echo "No port value found for $i"
continue
fi

# Determine command based on OS
case "$(uname)" in
"Linux")
ports=$(ss -tunlp | grep "$new_service_name" | awk '{print $5}' | awk -F '[:]' '{print $NF}')
;;
"Darwin")
ports=$(lsof -i -P | grep LISTEN | grep "$new_service_name" | awk '{print $9}' | awk -F '[:]' '{print $2}')
;;
*)
echo "Invalid service name: $i"
exit -1
echo "Unsupported operating system"
exit 1
;;
esac

port=$(ss -tunlp | grep "$new_service_name" | awk '{print $5}' | awk -F '[:]' '{print $NF}')
if [[ "$port" != "$new_service_port" ]]; then
echo -e "${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX} service does not start normally, not initiated port is ${COLOR_SUFFIX}${YELLOW_PREFIX}${new_service_port}${COLOR_SUFFIX}"
echo -e "${RED_PREFIX}please check ${SCRIPTS_ROOT}/../logs/openIM.log ${COLOR_SUFFIX}"
found_port=false
for port in $ports; do
if [[ "$port" == "$service_port" ]]; then
echo -e "${service_port}${GREEN_PREFIX} port has been listening, belongs service is ${new_service_name}${COLOR_SUFFIX}"
found_port=true
break
fi
done

if [[ "$found_port" != true ]]; then
echo -e "${YELLOW_PREFIX}${new_service_name}${COLOR_SUFFIX}${RED_PREFIX} service does not start normally, expected port is ${COLOR_SUFFIX}${YELLOW_PREFIX}${service_port}${COLOR_SUFFIX}"
echo -e "${RED_PREFIX}please check ${SCRIPTS_ROOT}/../logs/chat_$(date '+%Y%m%d').log ${COLOR_SUFFIX}"
exit -1
else
echo -e "${new_service_port}${GREEN_PREFIX} port has been listening, belongs service is ${i}${COLOR_SUFFIX}"
fi
done

4 changes: 2 additions & 2 deletions scripts/docker_start_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ for ((i = 0; i < ${#service_filenames[*]}; i++)); do
cmd="$bin_dir/$service_name -port $port --config_folder_path $config_path"
fi
echo "$cmd"
nohup $cmd >> "${logs_dir}/openIM.log" 2>&1 &
nohup $cmd >> "${logs_dir}/openim_$(date '+%Y%m%d').log" 2>&1 &
sleep 1
done
done

sleep 50
${OPENIM_ROOT}/scripts/check_all.sh

tail -f ${logs_dir}/openIM.log
tail -f ${logs_dir}/openim_$(date '+%Y%m%d').log
3 changes: 1 addition & 2 deletions scripts/path_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.



#Don't put the space between "="

#Include shell font styles and some basic information
Expand All @@ -39,6 +37,7 @@ declare -A supported_architectures=(
["linux-ppc64le"]="_output/bin/platforms/linux/ppc64le"
["linux-s390x"]="_output/bin/platforms/linux/s390x"
["darwin-amd64"]="_output/bin/platforms/darwin/amd64"
["darwin-arm64"]="_output/bin/platforms/darwin/arm64"
["windows-amd64"]="_output/bin/platforms/windows/amd64"
["linux-x86_64"]="_output/bin/platforms/linux/amd64" # Alias for linux-amd64
["darwin-x86_64"]="_output/bin/platforms/darwin/amd64" # Alias for darwin-amd64
Expand Down
20 changes: 18 additions & 2 deletions scripts/start_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,27 @@ echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
# fi

bin_dir="$BIN_DIR"
logs_dir="$SCRIPTS_ROOT/../logs"
logs_dir="$SCRIPTS_ROOT/../_output/logs"

echo -e "${YELLOW_PREFIX}=======>bin_dir=$bin_dir${COLOR_SUFFIX}"
echo -e "${YELLOW_PREFIX}=======>logs_dir=$logs_dir${COLOR_SUFFIX}"

# Define the path to the configuration file
CONFIG_FILE="${OPENIM_ROOT}/config/config.yaml"

# Check if the configuration file exists
if [ -f "$CONFIG_FILE" ]; then
# The file exists
echo "Configuration file already exists at $CONFIG_FILE."
else
echo ""
# The file does not exist
echo "Error: Configuration file does not exist."
echo "+++ You need to execute 'make init' to generate the configuration file and then modify the configuration items."
echo ""
exit 1
fi

#service filename
service_filename=(
chat-api
Expand Down Expand Up @@ -103,7 +119,7 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
cmd="$bin_dir/${service_filename[$i]} -port ${service_ports[$j]} --config_folder_path ${config_path}"
fi
echo $cmd
nohup $cmd >>${logs_dir}/openIM.log 2>&1 &
nohup $cmd >>${logs_dir}/openim_$(date '+%Y%m%d').log 2>&1 &
sleep 1
# pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
# echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:${service_ports[$j]} pid:$(eval $pid)$COLOR_SUFFIX"
Expand Down

0 comments on commit 66082d9

Please sign in to comment.