Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: script absolute path problem #134

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
Expand Down
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ EXCLUDE_TESTS=github.com/OpenIMSDK/chat/test

## all: Build all the necessary targets.
.PHONY: all
all: copyright-verify build # tidy lint cover
all: copyright-verify tidy build start check #lint cover

## build: Build binaries by default.
.PHONY: build
Expand Down Expand Up @@ -255,6 +255,24 @@ test:
cover: test
@$(GO) test -cover

## start: Start the chat all service.
.PHONY: start
start:
@echo "===========> Starting the service"
@$(ROOT_DIR)/scripts/start_all.sh

## check: Check the chat all service.
.PHONY: check
check:
@echo "===========> Checking the service"
@$(ROOT_DIR)/scripts/check_all.sh

## stop: Stop the chat all service.
.PHONY: stop
stop:
@echo "===========> Stopping the service"
@$(ROOT_DIR)/scripts/stop_all.sh

## docker-build: Build docker image with the manager.
.PHONY: docker-build
docker-build:
Expand Down
14 changes: 14 additions & 0 deletions internal/rpc/chat/statistic.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright © 2023 OpenIM open source community. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package chat

import (
Expand Down
45 changes: 13 additions & 32 deletions scripts/check_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,18 @@ service_port_name=(
openImChatPort
)

switch=$(cat $config_path | grep demoswitch | awk -F '[:]' '{print $NF}')
switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}')
for i in ${service_port_name[*]}; do
case $i in
"openImChatApiPort")
new_service_name="chat-api"
new_service_port="10008"
;;
"openImAdminApiPort")
new_service_name="admin-rpc"
new_service_port="30200"
;;
"openImAdminPort")
new_service_name="chat-rpc"
new_service_port="30300"
;;
"openImChatPort")
new_service_name="admin-api"
new_service_port="10009"
;;
*)
echo "Invalid service name: $i"
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}')
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}
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}"
exit -1
else
echo -e "${new_service_port}${GREEN_PREFIX} port has been listening, belongs service is ${i}${COLOR_SUFFIX}"
fi
done
else
echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX}
fi
done
done
14 changes: 14 additions & 0 deletions scripts/path_info.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



#Don't put the space between "="
Expand Down
4 changes: 2 additions & 2 deletions scripts/stop_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cd "$SCRIPTS_ROOT"

for i in ${service_names[*]}; do
#Check whether the service exists
name="ps -T |grep -w $i |grep -v grep"
name="ps -aux |grep -w $i |grep -v grep"
count="${name}| wc -l"
if [ $(eval ${count}) -gt 0 ]; then
pid="${name}| awk '{print \$2}'"
Expand All @@ -34,4 +34,4 @@ for i in ${service_names[*]}; do
kill -9 $(eval $pid)
echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}"
fi
done
done
Loading