Skip to content

Commit

Permalink
check_all scripts can't check if the service has started and stop_all…
Browse files Browse the repository at this point in the history
… script can't stop all service (#147)

* 143

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

* jiaoben

Signed-off-by: hanzhixiao <[email protected]>

---------

Signed-off-by: hanzhixiao <[email protected]>
  • Loading branch information
hanzhixiao authored Aug 18, 2023
1 parent 93c394f commit 2957be6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
9 changes: 0 additions & 9 deletions scripts/build_all_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,10 @@ echo -e "${BOLD_PREFIX}_________________________________________________________

bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/db/sdk/"

echo "==> bin_dir=$bin_dir"
echo "==> logs_dir=$logs_dir"
echo "==> sdk_db_dir=$sdk_db_dir"

# Automatically created when there is no bin, logs folder
if [ ! -d $logs_dir ]; then
mkdir -p $logs_dir
fi
if [ ! -d $sdk_db_dir ]; then
mkdir -p $sdk_db_dir
fi

cd $SCRIPTS_ROOT/..

Expand Down
2 changes: 1 addition & 1 deletion scripts/check_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for i in ${service_port_name[*]}; do
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
list_to_string $list
for j in ${ports_array}; do
port=$(ss -tunlp| grep -E 'api|rpc|openIm' | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
port=$(ss -tunlp| grep -E 'api|rpc|open_im' | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
if [[ ${port} -ne ${j} ]]; then
echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX}
echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX}
Expand Down
6 changes: 4 additions & 2 deletions scripts/start_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"

bin_dir="$BIN_DIR"
logs_dir="$SCRIPTS_ROOT/../logs"
sdk_db_dir="$SCRIPTS_ROOT/../sdk/db/"

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

#service filename
service_filename=(
Expand All @@ -65,6 +63,10 @@ service_prometheus_port_name=(

)

# Automatically created when there is no bin, logs folder
if [ ! -d $logs_dir ]; then
mkdir -p $logs_dir
fi
cd $SCRIPTS_ROOT

for ((i = 0; i < ${#service_filename[*]}; i++)); do
Expand Down
36 changes: 23 additions & 13 deletions scripts/stop_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,32 @@

#fixme This scripts is to stop the service
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
OPENIM_ROOT=$(cd $(dirname "${BASH_SOURCE[0]}")/.. &&pwd)

source $OPENIM_ROOT/scripts/style_info.sh
source $OPENIM_ROOT/scripts/path_info.sh
source $SCRIPTS_ROOT/function.sh

cd "$SCRIPTS_ROOT"
service_port_name=(
openImChatApiPort
openImAdminApiPort
#api port name
openImAdminPort
openImChatPort
)

for i in ${service_names[*]}; do
#Check whether the service exists
name="ps -aux |grep -w $i |grep -v grep"
count="${name}| wc -l"
if [ $(eval ${count}) -gt 0 ]; then
pid="${name}| awk '{print \$2}'"
echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}"
#kill the service that existed
kill -9 $(eval $pid)
echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}"
fi
for i in ${service_port_name[*]}; do
list=$(cat $OPENIM_ROOT/config/config.yaml | grep -w ${i} | awk -F '[:]' '{print $NF}')
list_to_string $list
for j in ${ports_array}; do
name="ps -aux |grep -w $j |grep -v grep"
count="${name}| wc -l"
if [ $(eval ${count}) -gt 0 ]; then
pid="${name}| awk '{print \$2}'"
echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}"
#kill the service that existed
kill -9 $(eval $pid)
echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}"
fi
done
done

0 comments on commit 2957be6

Please sign in to comment.