From d9e4899da5a695ea58b2b1a3a702d24726125ecc Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com> Date: Fri, 11 Aug 2023 15:13:37 +0800 Subject: [PATCH] feat: scripts feature extend Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --- Makefile | 15 ++++++++++----- docker-compose.yaml | 17 +++++++++++------ scripts/build_all_service.sh | 16 +++++++++++++--- scripts/docker_start_all.sh | 7 +++++++ scripts/make-rules/golang.mk | 12 ++++++++++++ scripts/start_all.sh | 13 +++++-------- scripts/verify-spelling.sh | 1 - scripts/verify-typecheck.sh | 1 - 8 files changed, 58 insertions(+), 24 deletions(-) mode change 100755 => 100644 scripts/docker_start_all.sh diff --git a/Makefile b/Makefile index 78ea2a66a..c6877b702 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,11 @@ export USAGE_OPTIONS # ============================================================================== # Targets +## demo: Run demo get started with Makefiles quickly ✨ +.PHONY: demo +demo: + @$(MAKE) go.demo + ## build: Build binaries by default ✨ .PHONY: build build: @@ -77,6 +82,11 @@ restart: clean stop build start multiarch: @$(MAKE) go.build.multiarch +## verify: execute all verity scripts. ✨ +.PHONY: verify +verify: + @$(MAKE) go.verify + ## install: Install deployment openim ✨ .PHONY: install install: @@ -205,11 +215,6 @@ advertise: release: release.verify release.ensure-tag @scripts/release.sh -## demo: Run demo ✨ -.PHONY: demo -demo: - @$(MAKE) go.demo - ## help: Show this help info. ✨ .PHONY: help help: Makefile diff --git a/docker-compose.yaml b/docker-compose.yaml index 84d478cd7..7d647c1d4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -99,8 +99,10 @@ services: command: minio server /data --console-address ':9090' openim-server: - image: ghcr.io/openimsdk/openim-server:latest -# build: . + # image: ghcr.io/openimsdk/openim-server:latest + image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:v3.2.1-beta.4 + # image: openim/openim-server:latest + # build: . container_name: openim-server volumes: - ./logs:/openim/openim-server/logs @@ -122,13 +124,16 @@ services: max-file: "2" openim-chat: - image: ghcr.io/openimsdk/openim-chat:latest + # image: ghcr.io/openimsdk/openim-chat:latest + image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:latest + # image: openim/openim-chat:latest container_name: openim-chat volumes: - - ./_output/openim/openim-chat/logs:/openim/openim-chat/logs - - ./_output/openim/openim-chat/config:/openim/openim-chat/config - - ./_output/openim/openim-chat/scripts:/openim/openim-chat/scripts + - ${DATA_DIR}/_output/openim/openim-chat/logs:/openim/openim-chat/logs + - ${DATA_DIR}/_output/openim/openim-chat/config:/openim/openim-chat/config + - ${DATA_DIR}/_output/openim/openim-chat/scripts:/openim/openim-chat/scripts restart: always + user: root:root depends_on: - mysql - mongodb diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh index dce28d79c..f7e131a95 100755 --- a/scripts/build_all_service.sh +++ b/scripts/build_all_service.sh @@ -19,7 +19,7 @@ # WHAT: Directory names to build. If any of these directories has a 'main' # package, the build will produce executable files under $(OUT_DIR)/bin/platforms OR $(OUT_DIR)/bin—tools/platforms. # If not specified, "everything" will be built. -# Usage: `scripts/build_all_server.sh`. +# Usage: `scripts/build_all_service.sh`. # Example: `hack/build-go.sh WHAT=cmd/kubelet`. set -o errexit @@ -45,7 +45,7 @@ else fi echo -e "${GREEN_PREFIX}======> cpu_count=$cpu_count${COLOR_SUFFIX}" -openim::log::status "Building OpenIM, Parallel compilation compile=$cpu_count" +openim::log::info "Building OpenIM, Parallel compilation compile=$cpu_count" compile_count=$((cpu_count / 2)) # For help output @@ -58,14 +58,24 @@ openim::color::echo $COLOR_CYAN "NOTE: $0 has been replaced by 'make multiarch' echo echo "The equivalent of this invocation is: " echo " make build ${ARGHELP}" +echo " ./scripts/build_all_service.sh ${ARGHELP}" echo echo " Example: " echo " Print a single binary:" echo " make build BINS=openim-api" +echo " ./scripts/build_all_service.sh BINS=openim-api" echo " Print : Enable debugging and logging" echo " make build BINS=openim-api V=1 DEBUG=1" +echo " ./scripts/build_all_service.sh BINS=openim-api V=1 DEBUG=1" echo -make --no-print-directory -C "${OPENIM_ROOT}" -j$compile_count build "$*" + +if [ -z "$*" ]; then + openim::log::info "no args, build all service" + make --no-print-directory -C "${OPENIM_ROOT}" -j$compile_count build +else + openim::log::info "build service: $*" + make --no-print-directory -C "${OPENIM_ROOT}" -j$compile_count build "$*" +fi if [ $? -eq 0 ]; then openim::log::success "all service build success, run 'make start' or './scripts/start_all.sh'" diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh old mode 100755 new mode 100644 index 24847e21e..3d7616c1e --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -58,3 +58,10 @@ sleep 15 #fixme prevents the openIM service exit after execution in the docker container tail -f /dev/null + +# nohup ./bin/seata-server.sh > ./logs/seata.log.out 2>&1 & + +# # seata注册到nacos的ip和端口,不配置默认获取本机ip(docker容器ip) +# echo $SEATA_IP $SEATA_PORT + +# tail -f logs/seata.log.out \ No newline at end of file diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index 7cff9d42b..36f9a74bc 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -213,6 +213,18 @@ go.format: tools.verify.golines tools.verify.goimports go.imports: tools.verify.goimports @$(TOOLS_DIR)/goimports -l -w $(SRC) +## verify: execute all verity scripts. +.PHONY: go.verify +go.verify: + @echo "Starting verification..." + @scripts_list=$$(find $(ROOT_DIR)/scripts -type f -name 'verify-*' | sort); \ + for script in $$scripts_list; do \ + echo "Executing $$script..."; \ + $$script || exit 1; \ + echo "$$script completed successfully"; \ + done + @echo "All verification scripts executed successfully." + ## go.updates: Check for updates to go.mod dependencies .PHONY: go.updates go.updates: tools.verify.go-mod-outdated diff --git a/scripts/start_all.sh b/scripts/start_all.sh index 6b7ebe74b..d746c9fb8 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -16,15 +16,12 @@ #FIXME This script is the startup script for multiple servers. #FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array. -#Include shell font styles and some basic information -SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/.. +set -o errexit +set -o nounset +set -o pipefail -#Include shell font styles and some basic information -source $SCRIPTS_ROOT/lib/init.sh -source $SCRIPTS_ROOT/path_info.sh - -cd $SCRIPTS_ROOT +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +source "${OPENIM_ROOT}/scripts/lib/init.sh" if [ ! -d "${OPENIM_ROOT}/_output/bin/platforms" ]; then # exec build_all_service.sh diff --git a/scripts/verify-spelling.sh b/scripts/verify-spelling.sh index 41be8053a..487c68cde 100755 --- a/scripts/verify-spelling.sh +++ b/scripts/verify-spelling.sh @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - # This script checks commonly misspelled English words in all files in the # working directory by client9/misspell package. # Usage: `scripts/verify-spelling.sh`. diff --git a/scripts/verify-typecheck.sh b/scripts/verify-typecheck.sh index 4792c9ab3..0aa79482a 100755 --- a/scripts/verify-typecheck.sh +++ b/scripts/verify-typecheck.sh @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - # This script does a fast type check of script srnetes code for all platforms. # Usage: `scripts/verify-typecheck.sh`.