Files
open-im-server/script/sdk_svr_start.sh
T

46 lines
1.9 KiB
Bash
Raw Normal View History

2021-09-27 21:05:52 +08:00
#!/usr/bin/env bash
#Include shell font styles and some basic information
source ./style_info.cfg
source ./path_info.cfg
source ./function.sh
2022-04-27 10:09:05 +08:00
ulimit -n 200000
2022-08-24 16:15:24 +08:00
ws_address=$(cat $config_path | grep openImWsAddress | awk -F '[ ]' '{print $NF}')
api_address=$(cat $config_path | grep openImApiAddress | awk -F '[ ]' '{print $NF}')
2021-10-08 17:50:09 +08:00
list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}')
2022-03-04 16:24:28 +08:00
logLevel=$(cat $config_path | grep remainLogLevel | awk -F '[:]' '{print $NF}')
2021-09-27 21:05:52 +08:00
list_to_string $list3
2023-02-09 20:36:34 +08:00
sdkws_ports=($ports_array)
2021-09-27 21:05:52 +08:00
#Check if the service exists
#If it is exists,kill this process
check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l)
if [ $check -ge 1 ]; then
oldPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}')
kill -9 ${oldPid}
fi
#Waiting port recycling
sleep 1
2021-09-28 20:21:04 +08:00
cd ${sdk_server_binary_root}
2023-03-09 15:34:42 +08:00
nohup ./${sdk_server_name} -openIM_ws_address ${ws_address} -sdk_ws_port ${sdkws_ports[0]} -openIM_api_address ${api_address} -openIM_log_level ${logLevel} >>../logs/openIM.log 2>&1 &
2021-09-27 21:05:52 +08:00
#Check launched service process
sleep 3
check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l)
allPorts=""
if [ $check -ge 1 ]; then
allNewPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}')
for i in $allNewPid; do
ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}')
allPorts=${allPorts}"$ports "
done
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
else
2021-10-26 12:02:07 +08:00
echo -e ${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR PLEASE CHECK openIM.log"${COLOR_SUFFIX}
2021-09-27 21:05:52 +08:00
fi