From 48df76fb8bc10841d4f3c9e85b830fcd46c3cd53 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751NSS@gmail.com> Date: Sun, 31 Mar 2024 12:40:35 +0800 Subject: [PATCH 01/86] docs: update openim images docs deployment aliyun (#2154) --- docs/contrib/images.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/contrib/images.md b/docs/contrib/images.md index d1a83d639..396ffb2e3 100644 --- a/docs/contrib/images.md +++ b/docs/contrib/images.md @@ -96,4 +96,21 @@ When pulling OpenIM's Docker images, you can choose the most suitable source bas 3. Run the `docker images` command to confirm that the image has been successfully pulled. -This concludes OpenIM's image management strategy and the steps for pulling images. If you have any questions, please feel free to ask. +### Accelerating Deployment for Users in China with Aliyun Mirror or Alternative Image Addresses + +For users in China looking to speed up the deployment process of OpenIM, leveraging a mirror image address is a highly recommended practice. After executing the `make init` command, a `.env` file is generated, which you'll need to edit to configure the image registry source. This configuration is crucial for optimizing download speeds and ensuring a smoother setup process. + +Within the generated `.env` file, you'll find a section dedicated to choosing the image address. It includes options for GitHub (`ghcr.io/openimsdk`), Docker Hub (`openim`), and Ali Cloud (`registry.cn-hangzhou.aliyuncs.com/openimsdk`). To achieve the best performance within China, it is advised to use the Aliyun image address. + +To do this, you need to comment out the current `IMAGE_REGISTRY` setting and uncomment the Aliyun option. Here is how you can adjust it for Aliyun: + +```bash +# Choose the image address: GitHub (ghcr.io/openimsdk), Docker Hub (openim), +# or Ali Cloud (registry.cn-hangzhou.aliyuncs.com/openimsdk). +# Uncomment one of the following three options. Aliyun is recommended for users in China. +# IMAGE_REGISTRY="ghcr.io/openimsdk" +# IMAGE_REGISTRY="openim" +IMAGE_REGISTRY="registry.cn-hangzhou.aliyuncs.com/openimsdk" +``` + +This change directs the deployment process to fetch the required images from the Aliyun registry, significantly improving download and installation speeds due to the geographical and network advantages within China. If, for any reason, you prefer not to use Aliyun or encounter issues, consider switching to another mirror address listed in the `.env` file by following the same uncommenting process. This flexibility ensures that users can select the most suitable image source for their specific situation, leading to a more efficient deployment of OpenIM. From 4f40022105bc6d671bb04c4831ceb961c6f02bee Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751NSS@gmail.com> Date: Tue, 2 Apr 2024 11:31:25 +0800 Subject: [PATCH 02/86] feat: Enhancements to OpenIM Engineering Practices with Standardizer and Tool Versioning (#2159) * feat: add standardizer optimize makefile * feat: add standardizer optimize makefile * feat: add openim test docs * feat: add openim kafka docs * feat: add openim kafka docs * feat: add openim kafka docs --- .github/code-language-detector.yml | 1 + .github/release-drafter.yml | 2 +- .github/standardizer.yml | 50 ++++++ .github/workflows/openimci.yml | 3 + Makefile | 1 + README_zh_CN.md | 2 +- docker-compose-1.yml | 2 +- docker-compose.yml | 2 +- docs/contrib/kafka.md | 162 ++++++++++++++++++ docs/contrib/logging.md | 2 +- docs/contrib/test.md | 86 +++++++++- docs/images/Open-IM.png | Bin 17614 -> 0 bytes .../{Architecture.jpg => architecture.jpg} | Bin docs/images/{Wechat.jpg => wechat.jpg} | Bin go.work | 1 - .../{directResolver.go => direct_resolver.go} | 0 scripts/lib/golang.sh | 3 - scripts/lib/release.sh | 2 +- scripts/make-rules/common-versions.mk | 58 +++++++ scripts/make-rules/common.mk | 7 + scripts/make-rules/tools.mk | 110 +++++++----- scripts/verify-standardizer.sh | 33 ++++ .../{sendMessage.json => send-message.json} | 0 tools/formitychecker/README.md | 102 ----------- tools/formitychecker/checker/checker.go | 113 ------------ tools/formitychecker/config/config.go | 41 ----- tools/formitychecker/formitychecker.go | 41 ----- tools/formitychecker/go.mod | 3 - 28 files changed, 472 insertions(+), 355 deletions(-) create mode 100644 .github/standardizer.yml create mode 100644 docs/contrib/kafka.md delete mode 100644 docs/images/Open-IM.png rename docs/images/{Architecture.jpg => architecture.jpg} (100%) rename docs/images/{Wechat.jpg => wechat.jpg} (100%) rename pkg/common/discoveryregister/direct/{directResolver.go => direct_resolver.go} (100%) create mode 100644 scripts/make-rules/common-versions.mk create mode 100755 scripts/verify-standardizer.sh rename test/testdata/requests/{sendMessage.json => send-message.json} (100%) delete mode 100644 tools/formitychecker/README.md delete mode 100644 tools/formitychecker/checker/checker.go delete mode 100644 tools/formitychecker/config/config.go delete mode 100644 tools/formitychecker/formitychecker.go delete mode 100644 tools/formitychecker/go.mod diff --git a/.github/code-language-detector.yml b/.github/code-language-detector.yml index 32a8c1f54..194c2474a 100644 --- a/.github/code-language-detector.yml +++ b/.github/code-language-detector.yml @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +# https://github.com/marketplace/actions/code-language-detector directory: ./ file_types: - .go diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 154386ff5..55ee241d7 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -48,4 +48,4 @@ template: | ## Contributors to this $REPOSITORY release - $CONTRIBUTORS \ No newline at end of file + $CONTRIBUTORS diff --git a/.github/standardizer.yml b/.github/standardizer.yml new file mode 100644 index 000000000..fceb69df1 --- /dev/null +++ b/.github/standardizer.yml @@ -0,0 +1,50 @@ +# https://github.com/marketplace/actions/conformity-checker-for-project +baseConfig: + searchDirectory: "./" + ignoreCase: false + +directoryNaming: + allowHyphens: true + allowUnderscores: false + mustBeLowercase: true + +fileNaming: + allowHyphens: true + allowUnderscores: true + mustBeLowercase: true + +ignoreFormats: + - "\\.log$" + - "\\.env$" + - "README\\.md$" + - "_test\\.go$" + - "\\.md$" + - _test\\.txt$ + - LICENSE + - Dockerfile + - CODEOWNERS + - Makefile + +ignoreDirectories: + - "vendor" + - ".git" + - "deployments" + - "node_modules" + - "logs" + - "CHANGELOG" + - "components" + - "_output" + - "tools/openim-web" + - "CHANGELOG" + - "examples/Test_directory" + - test/testdata + +fileTypeSpecificNaming: + ".yaml": + allowHyphens: true + allowUnderscores: false + mustBeLowercase: true + ".go": + allowHyphens: false + allowUnderscores: true + mustBeLowercase: true \ No newline at end of file diff --git a/.github/workflows/openimci.yml b/.github/workflows/openimci.yml index 5aeddd09a..f47283997 100644 --- a/.github/workflows/openimci.yml +++ b/.github/workflows/openimci.yml @@ -73,6 +73,9 @@ jobs: - name: Code Typecheck Detector uses: kubecub/typecheck@main + - name: Conformity Checker for Project + uses: kubecub/standardizer@main + - name: Module Operations run: | sudo make tidy diff --git a/Makefile b/Makefile index 89b9e4152..818372fb8 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ VERSION_PACKAGE=github.com/openimsdk/open-im-server/v3/pkg/version # Includes include scripts/make-rules/common.mk # make sure include common.mk at the first include line +include scripts/make-rules/common-versions.mk include scripts/make-rules/golang.mk include scripts/make-rules/image.mk include scripts/make-rules/copyright.mk diff --git a/README_zh_CN.md b/README_zh_CN.md index 7eabfa509..f42031165 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -52,7 +52,7 @@

## 🟢 扫描微信进群交流 - + ## Ⓜ️ 关于 OpenIM diff --git a/docker-compose-1.yml b/docker-compose-1.yml index 39fc944ce..ed852fd29 100644 --- a/docker-compose-1.yml +++ b/docker-compose-1.yml @@ -1,4 +1,4 @@ -#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/OpenIMSDK/Open-IM-Server.git +#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/openimsdk/open-im-server.git # The command that triggers this file to pull the image is "docker compose up -f" version: '3' diff --git a/docker-compose.yml b/docker-compose.yml index ef0714329..a983acbaf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/OpenIMSDK/Open-IM-Server.git +#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/openimsdk/open-im-server.git # The command that triggers this file to pull the image is "docker compose up -d". version: '3' diff --git a/docs/contrib/kafka.md b/docs/contrib/kafka.md new file mode 100644 index 000000000..4547c9480 --- /dev/null +++ b/docs/contrib/kafka.md @@ -0,0 +1,162 @@ +# OpenIM Kafka Guide + +This document aims to provide a set of concise guidelines to help you quickly install and use Kafka through Docker Compose. + +## Installing Kafka + +With the Docker Compose script provided by OpenIM, you can easily install Kafka. Use the following command to start Kafka: + +```bash +docker compose up -d +``` + +After executing this command, Kafka will be installed and started. You can confirm the Kafka container is running with the following command: + +```bash +docker ps | grep kafka +``` + +The output of this command, as shown below, displays the status information of the Kafka container: + +``` +be416b5a0851 bitnami/kafka:3.5.1 "/opt/bitnami/script…" 3 days ago Up 2 days 9092/tcp, 0.0.0.0:19094->9094/tcp, :::19094->9094/tcp kafka +``` + +### References + +- Official Docker installation documentation: [Click here](http://events.jianshu.io/p/b60afa35303a) +- Detailed installation guide: [Tutorial on Towards Data Science](https://towardsdatascience.com/how-to-install-apache-kafka-using-docker-the-easy-way-4ceb00817d8b) + +## Using Kafka + +### Entering the Kafka Container + +To execute Kafka commands, you first need to enter the Kafka container. Use the following command: + +```bash +docker exec -it kafka bash +``` + +### Kafka Command Tools + +Inside the Kafka container, you can use various command-line tools to manage Kafka. These tools include but are not limited to: + +- `kafka-topics.sh`: For creating, deleting, listing, or altering topics. +- `kafka-console-producer.sh`: Allows sending messages to a specified topic from the command line. +- `kafka-console-consumer.sh`: Allows reading messages from the command line, with the ability to specify topics. +- `kafka-consumer-groups.sh`: For managing consumer group information. + +### Kafka Client Tool Installation + +For easier Kafka management, you can install Kafka client tools. If you installed Kafka through OpenIM's Docker Compose, you can install the Kafka client tools with the following command: + +```bash +make install.kafkactl +``` + +### Automatic Topic Creation + +When installing Kafka through OpenIM's Docker Compose method, OpenIM automatically creates the following topics: + +- `latestMsgToRedis` +- `msgToPush` +- `offlineMsgToMongoMysql` + +These topics are created using the `scripts/create-topic.sh` script. The script waits for Kafka to be ready before executing the commands to create topics: + +```bash +# Wait for Kafka to be ready +until /opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092; do + echo "Waiting for Kafka to be ready..." + sleep 2 +done + +# Create topics +/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic latestMsgToRedis +/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic msgToPush +/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic offlineMsgToMongoMysql + +echo "Topics created." +``` + +The optimized and expanded documentation further details some basic commands for operations inside the Kafka container, as well as basic commands for managing Kafka using `kafkactl`. Here is a more detailed guide. + + +## Basic Commands in the Kafka Container + +### Listing Topics + +To list all existing topics, you can use the following command: + +```bash +kafka-topics.sh --list --bootstrap-server localhost:9092 +``` + +### Creating a New Topic + +When creating a new topic, you can specify the number of partitions and the replication factor. Here is the command to create a new topic: + +```bash +kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic your_topic_name +``` + +### Producing Messages + +To send messages to a specific topic, you can use the producer command. The following command prompts you to enter messages, which are sent to the specified topic with each press of the Enter key: + +```bash +kafka-console-producer.sh --broker-list localhost:9092 --topic your_topic_name +``` + +### Consuming Messages + +To read messages from a specific topic, you can use the consumer command. The following command reads new messages from the specified topic and outputs them on the console: + +```bash +kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic your_topic_name --from-beginning +``` + +The ` + +--from-beginning` parameter reads messages from the beginning of the topic. If this parameter is omitted, only new messages will be read. + + +## Basic Commands Using `kafkactl` + +`kafkactl` is a command-line tool for managing and operating Kafka clusters. It offers a more modern way to interact with Kafka. + +### Listing Topics + +To list all topics, you can use: + +```bash +kafkactl get topics +``` + +### Creating a New Topic + +To create a new topic with `kafkactl`, use: + +```bash +kafkactl create topic your_topic_name --partitions 1 --replication-factor 1 +``` + +### Producing Messages + +To send messages to a topic, you can use: + +```bash +kafkactl produce your_topic_name --value "your message" +``` + +Here, `"your message"` is the content of the message you want to send. + +### Consuming Messages + +To consume messages from a topic, use: + +```bash +kafkactl consume your_topic_name --from-beginning +``` + +Again, the `--from-beginning` parameter will start consuming messages from the beginning of the topic. If you do not wish to start from the beginning, you can omit this parameter. \ No newline at end of file diff --git a/docs/contrib/logging.md b/docs/contrib/logging.md index e4774929c..c44f6f3c7 100644 --- a/docs/contrib/logging.md +++ b/docs/contrib/logging.md @@ -2,7 +2,7 @@ ## Script Logging Documentation Link -If you wish to view the script's logging documentation, you can click on this link: [Logging Documentation](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/contrib/bash-log.md). +If you wish to view the script's logging documentation, you can click on this link: [Logging Documentation](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/bash-log.md). Below is the documentation for logging and error handling in the OpenIM Go project. diff --git a/docs/contrib/test.md b/docs/contrib/test.md index 37c1792cf..2470a0537 100644 --- a/docs/contrib/test.md +++ b/docs/contrib/test.md @@ -2,14 +2,94 @@ This document serves as a comprehensive guide to understanding and utilizing the `test.sh` script for testing OpenIM RPC services. The `test.sh` script is a collection of bash functions designed to test various aspects of the OpenIM RPC services, ensuring that each part of the API is functioning as expected. -+ Scripts:https://github.com/OpenIMSDK/Open-IM-Server/tree/main/scripts/install/test.sh ++ Scripts:https://github.com/openimsdk/open-im-server/tree/main/scripts/install/test.sh -For some complex, bulky functional tests, performance tests, and various e2e tests, We are all in the current warehouse to https://github.com/OpenIMSDK/Open-IM-Server/tree/main/test or https://github.com/openim-sigs/test-infra directory In the. +For some complex, bulky functional tests, performance tests, and various e2e tests, We are all in the current warehouse to https://github.com/openimsdk/open-im-server/tree/main/test or https://github.com/openim-sigs/test-infra directory In the. + About OpenIM Feature [Test Docs](https://docs.google.com/spreadsheets/d/1zELWkwxgOOZ7u5pmYCqqaFnvZy2SVajv/edit?usp=sharing&ouid=103266350914914783293&rtpof=true&sd=true) +## Util Test -## Usage +Let's restructure and enhance the document under a unified second-level heading, adding clarity and details for better comprehension and visual appeal. + +--- + +## Development Guide + +### Comprehensive Testing Instructions + +#### Running Unit Tests + +- **Command**: To execute unit tests, input the following in your terminal: + ``` + make test + ``` + +#### Evaluating Test Coverage + +- **Overview**: It's crucial to assess how much of your code is covered by tests. +- **Command**: + ```bash + make cover + ``` + This command generates a report detailing the percentage of your code tested, ensuring adherence to quality standards. + +#### Conducting API Tests + +- **Purpose**: API tests validate the interaction and functionality of your application's interfaces. +- **How to Run**: + ``` + make test-api + ``` + Use this to check the integrity and reliability of your API endpoints. + +#### End-to-End (E2E) Testing + +- **Scope**: E2E tests simulate real-user scenarios from start to finish. +- **Execution**: + ``` + make test-e2e + ``` + This comprehensive testing ensures your application performs as expected in real-world situations. + +### Crafting Unit Test Cases + +#### Setup for Test Case Generation + +- **Installation**: Install the `gotests` tool to generate test cases automatically. + ```bash + make install.gotests + ``` + This command installs the `gotests` tool for test case generation. + +- **Environment Preparation**: Define your test template environment variable and generate test cases as shown below: + ```bash + export GOTESTS_TEMPLATE=testify + gotests -i -w -only keyFunc . + ``` + This prepares your environment for test case generation using the `testify` template. + +#### Isolating Function Tests + +- **Single Function Testing**: When you need to focus on testing a single function for detailed examination. +- **Method**: + ```bash + go test -v -run TestKeyFunc + ``` + This command specifically runs tests for `TestKeyFunc`, allowing targeted debugging and validation. + +### Important Note + +- **Quality Assurance**: Throughout your development process, it is imperative to ensure that the unit test coverage meets or surpasses the standards set by OpenIM. +- **Maintaining Standards**: Regularly running your tests with + ```make test``` + supports maintaining high code quality and adherence to OpenIM's rigorous testing benchmarks. + +## E2E Test + +TODO + +## Api Test The `test.sh` script is located within the `./scripts/install/` directory of the OpenIM service's codebase. To use the script, navigate to this directory from your terminal: diff --git a/docs/images/Open-IM.png b/docs/images/Open-IM.png deleted file mode 100644 index b617065505626ea5df9467ca5e945f851258aee6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17614 zcmZU*2RNJU8#Z3r(we3AtWs)Io1nF+)vAas6t!zhtkRa+_1d+HqLmpsu(y6z`JUss)+go)(FjT_{e8Y(Yu+#rPG|Nd}? z2>)rA3sJ)VBJg~vu5_bhfMo;!<(B<3oo6?0l*N(az_;<=@4nSA_PlX}qV3NQL8sgI z*Eepc*l4Oed*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JI$h=hR`Z*&j9p z{aGcp=56pP#7bDpIRRB+s;_`sxTBcm!oa6;K#u1)mS4PQby85}Sb4q9e07i?OPXGV_ diff --git a/docs/images/Architecture.jpg b/docs/images/architecture.jpg similarity index 100% rename from docs/images/Architecture.jpg rename to docs/images/architecture.jpg diff --git a/docs/images/Wechat.jpg b/docs/images/wechat.jpg similarity index 100% rename from docs/images/Wechat.jpg rename to docs/images/wechat.jpg diff --git a/go.work b/go.work index 02e4154d3..7cc1b80a1 100644 --- a/go.work +++ b/go.work @@ -4,7 +4,6 @@ use ( . ./tools/changelog ./tools/component - ./tools/formitychecker ./tools/imctl ./tools/infra ./tools/ncpu diff --git a/pkg/common/discoveryregister/direct/directResolver.go b/pkg/common/discoveryregister/direct/direct_resolver.go similarity index 100% rename from pkg/common/discoveryregister/direct/directResolver.go rename to pkg/common/discoveryregister/direct/direct_resolver.go diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 7b9d7e60c..f9648cbdb 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -314,9 +314,6 @@ openim::golang::setup_platforms readonly OPENIM_CLIENT_TARGETS=( changelog component - conversion-msg - conversion-mysql - formitychecker imctl infra ncpu diff --git a/scripts/lib/release.sh b/scripts/lib/release.sh index c1fbd00a1..05e92377d 100755 --- a/scripts/lib/release.sh +++ b/scripts/lib/release.sh @@ -243,7 +243,7 @@ function openim::release::package_client_tarballs() { local client_bins=("${OPENIM_CLIENT_BINARIES[@]}") - # client_bins: changelog component conversion-msg conversion-mysql formitychecker imctl infra ncpu openim-web up35 versionchecker yamlfmt + # client_bins: changelog component imctl infra ncpu openim-web up35 versionchecker yamlfmt # Copy client binclient_bins:aries openim::log::info " Copy client binaries: ${client_bins[@]/#/${LOCAL_OUTPUT_BINTOOLSPATH}/${platform}/}" openim::log::info " Copy client binaries to: ${release_stage}/client/bin" diff --git a/scripts/make-rules/common-versions.mk b/scripts/make-rules/common-versions.mk new file mode 100644 index 000000000..572585fce --- /dev/null +++ b/scripts/make-rules/common-versions.mk @@ -0,0 +1,58 @@ +# Copyright © 2023 OpenIMSDK. +# +# 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. +# ============================================================================== +# OpenIM Makefile Versions used +# +# Define the latest version for each tool to ensure consistent versioning across installations +GOLANGCI_LINT_VERSION ?= latest +GOIMPORTS_VERSION ?= latest +ADDLICENSE_VERSION ?= latest +DEEPCOPY_GEN_VERSION ?= latest +CONVERSION_GEN_VERSION ?= latest +GINKGO_VERSION ?= v1.16.2 +GO_GITLINT_VERSION ?= latest +GO_JUNIT_REPORT_VERSION ?= latest +GOTESTS_VERSION ?= latest +SWAGGER_VERSION ?= latest +KUBE_SCORE_VERSION ?= latest +KUBECONFORM_VERSION ?= latest +GSEMVER_VERSION ?= latest +GIT_CHGLOG_VERSION ?= latest +KO_VERSION ?= latest +GITHUB_RELEASE_VERSION ?= latest +COSCLI_VERSION ?= v0.19.0-beta +MINIO_VERSION ?= latest +DELVE_VERSION ?= latest +AIR_VERSION ?= latest +GOLINES_VERSION ?= latest +GO_MOD_OUTDATED_VERSION ?= latest +CFSSL_VERSION ?= latest +DEPTH_VERSION ?= latest +GO_CALLVIS_VERSION ?= latest +MISSPELL_VERSION ?= latest +GOTHANKS_VERSION ?= latest +RICHGO_VERSION ?= latest +RTS_VERSION ?= latest +TYPECHECK_VERSION ?= latest +COMMENT_LANG_DETECTOR_VERSION ?= latest +STANDARDIZER_VERSION ?= latest +GO_TESTS_VERSION ?= v1.6.0 +GO_APIDIFF_VERSION ?= v0.8.2 +KAFKACTL_VERSION ?= latest +GOTESTSUM_VERSION ?= latest + +WIRE_VERSION ?= latest +# WIRE_VERSION ?= $(call get_go_version,github.com/google/wire) +MOCKGEN_VERSION ?= $(call get_go_version,github.com/golang/mock) +PROTOC_GEN_GO_VERSION ?= $(call get_go_version,github.com/golang/protobuf/protoc-gen-go) \ No newline at end of file diff --git a/scripts/make-rules/common.mk b/scripts/make-rules/common.mk index f8537b6ca..ffbb69a55 100644 --- a/scripts/make-rules/common.mk +++ b/scripts/make-rules/common.mk @@ -78,6 +78,13 @@ VERSION := $(shell git describe --tags --always --match='v*') # v2.3.3: git tag endif +# Helper function to get dependency version from go.mod +get_gomod_version = $(shell go list -m $1 | awk '{print $$2}') +define go_install +$(info ===========> Installing $(1)@$(2)) +$(GO) install $(1)@$(2) +endef + # Check if the tree is dirty. default to dirty(maybe u should commit?) GIT_TREE_STATE:="dirty" ifeq (, $(shell git status --porcelain 2>/dev/null)) diff --git a/scripts/make-rules/tools.mk b/scripts/make-rules/tools.mk index 917c18cfe..5335d094d 100644 --- a/scripts/make-rules/tools.mk +++ b/scripts/make-rules/tools.mk @@ -64,81 +64,101 @@ tools.verify.%: ## install.golangci-lint: Install golangci-lint .PHONY: install.golangci-lint install.golangci-lint: - @$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + @$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) ## install.goimports: Install goimports, used to format go source files .PHONY: install.goimports install.goimports: - @$(GO) install golang.org/x/tools/cmd/goimports@latest + @$(GO) install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION) ## install.addlicense: Install addlicense, used to add license header to source files .PHONY: install.addlicense install.addlicense: - @$(GO) install github.com/google/addlicense@latest + @$(GO) install github.com/google/addlicense@$(ADDLICENSE_VERSION) ## install.deepcopy-gen: Install deepcopy-gen, used to generate deep copy functions .PHONY: install.deepcopy-gen install.deepcopy-gen: - @$(GO) install k8s.io/code-generator/cmd/deepcopy-gen@latest + @$(GO) install k8s.io/code-generator/cmd/deepcopy-gen@$(DEEPCOPY_GEN_VERSION) ## install.conversion-gen: Install conversion-gen, used to generate conversion functions .PHONY: install.conversion-gen install.conversion-gen: - @$(GO) install k8s.io/code-generator/cmd/conversion-gen@latest + @$(GO) install k8s.io/code-generator/cmd/conversion-gen@$(CONVERSION_GEN_VERSION) ## install.ginkgo: Install ginkgo to run a single test or set of tests .PHONY: install.ginkgo install.ginkgo: - @$(GO) install github.com/onsi/ginkgo/ginkgo@v1.16.2 + @$(GO) install github.com/onsi/ginkgo/ginkgo@$(GINKGO_VERSION) -## Install go-gitlint: Install go-gitlint, used to check git commit message +## install.go-gitlint: Install go-gitlint, used to check git commit message .PHONY: install.go-gitlint install.go-gitlint: - @$(GO) install github.com/marmotedu/go-gitlint/cmd/go-gitlint@latest + @$(GO) install github.com/marmotedu/go-gitlint/cmd/go-gitlint@$(GO_GITLINT_VERSION) ## install.go-junit-report: Install go-junit-report, used to convert go test output to junit xml .PHONY: install.go-junit-report install.go-junit-report: - @$(GO) install github.com/jstemmer/go-junit-report@latest + @$(GO) install github.com/jstemmer/go-junit-report@$(GO_JUNIT_REPORT_VERSION) ## install.gotests: Install gotests, used to generate go tests +.PHONY: install.gotests +install.gotests: + @$(GO) install github.com/cweill/gotests/gotests@$(GO_TESTS_VERSION) + +## install.kafkactl: Install kafkactl command line tool. +.PHONY: install.kafkactl +install.kafkactl: + @$(GO) install github.com/deviceinsight/kafkactl@$(KAFKACTL_VERSION) + +## install.go-apidiff: Install go-apidiff, used to check api changes +.PHONY: install.go-apidiff +install.go-apidiff: + @$(GO) install github.com/joelanford/go-apidiff@$(GO_APIDIFF_VERSION) + +## install.swagger: Install swagger, used to generate swagger documentation .PHONY: install.swagger install.swagger: - @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@latest + @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@$(SWAGGER_VERSION) # ============================================================================== # Tools that might be used include go gvm # +## install.gotestsum: Install gotestsum, used to run go tests +.PHONY: install.gotestsum +install.gotestsum: + @$(GO) install gotest.tools/gotestsum@$(GOTESTSUM_VERSION) + ## install.kube-score: Install kube-score, used to check kubernetes yaml files .PHONY: install.kube-score install.kube-score: - @$(GO) install github.com/zegl/kube-score/cmd/kube-score@latest + @$(GO) install github.com/zegl/kube-score/cmd/kube-score@$(KUBE_SCORE_VERSION) ## install.kubeconform: Install kubeconform, used to check kubernetes yaml files .PHONY: install.kubeconform install.kubeconform: - @$(GO) install github.com/yannh/kubeconform/cmd/kubeconform@latest + @$(GO) install github.com/yannh/kubeconform/cmd/kubeconform@$(KUBECONFORM_VERSION) ## install.gsemver: Install gsemver, used to generate semver .PHONY: install.gsemver install.gsemver: - @$(GO) install github.com/arnaud-deprez/gsemver@latest + @$(GO) install github.com/arnaud-deprez/gsemver@$(GSEMVER_VERSION) ## install.git-chglog: Install git-chglog, used to generate changelog .PHONY: install.git-chglog install.git-chglog: - @$(GO) install github.com/git-chglog/git-chglog/cmd/git-chglog@latest + @$(GO) install github.com/git-chglog/git-chglog/cmd/git-chglog@$(GIT_CHGLOG_VERSION) ## install.ko: Install ko, used to build go program into container images .PHONY: install.ko install.ko: - @$(GO) install github.com/google/ko@latest + @$(GO) install github.com/google/ko@$(KO_VERSION) ## install.github-release: Install github-release, used to create github release .PHONY: install.github-release install.github-release: - @$(GO) install github.com/github-release/github-release@latest + @$(GO) install github.com/github-release/github-release@$(GITHUB_RELEASE_VERSION) ## install.coscli: Install coscli, used to upload files to cos # example: ./coscli cp/sync -r /home/off-line/docker-off-line/ cos://openim-1306374445/openim/image/amd/off-line/off-line/ -e cos.ap-guangzhou.myqcloud.com @@ -146,7 +166,7 @@ install.github-release: # amd64 .PHONY: install.coscli install.coscli: - @wget -q https://github.com/tencentyun/coscli/releases/download/v0.19.0-beta/coscli-linux -O ${TOOLS_DIR}/coscli + @wget -q https://github.com/tencentyun/coscli/releases/download/$(COSCLI_VERSION)/coscli-linux -O ${TOOLS_DIR}/coscli @chmod +x ${TOOLS_DIR}/coscli ## install.coscmd: Install coscmd, used to upload files to cos @@ -157,50 +177,50 @@ install.coscmd: ## install.minio: Install minio, used to upload files to minio .PHONY: install.minio install.minio: - @$(GO) install github.com/minio/minio@latest + @$(GO) install github.com/minio/minio@$(MINIO_VERSION) ## install.delve: Install delve, used to debug go program .PHONY: install.delve install.delve: - @$(GO) install github.com/go-delve/delve/cmd/dlv@latest + @$(GO) install github.com/go-delve/delve/cmd/dlv@$(DELVE_VERSION) ## install.air: Install air, used to hot reload go program .PHONY: install.air install.air: - @$(GO) install github.com/cosmtrek/air@latest + @$(GO) install github.com/cosmtrek/air@$(AIR_VERSION) ## install.gvm: Install gvm, gvm is a Go version manager, built on top of the official go tool. -# github: https://github.com/moovweb/gvm .PHONY: install.gvm install.gvm: - @echo "===========> Installing gvm,The default installation path is ~/.gvm/scripts/gvm" + @echo "===========> Installing gvm, The default installation path is ~/.gvm/scripts/gvm" @bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) - @$(shell source /root/.gvm/scripts/gvm) + @source /root/.gvm/scripts/gvm ## install.golines: Install golines, used to format long lines .PHONY: install.golines install.golines: - @$(GO) install github.com/segmentio/golines@latest + @$(GO) install github.com/segmentio/golines@$(GOLINES_VERSION) ## install.go-mod-outdated: Install go-mod-outdated, used to check outdated dependencies .PHONY: install.go-mod-outdated install.go-mod-outdated: - @$(GO) install github.com/psampaz/go-mod-outdated@latest + @$(GO) install github.com/psampaz/go-mod-outdated@$(GO_MOD_OUTDATED_VERSION) ## install.mockgen: Install mockgen, used to generate mock functions .PHONY: install.mockgen install.mockgen: - @$(GO) install github.com/golang/mock/mockgen@latest + @$(GO) install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION) + +## install.wire: Install wire, used to generate wire files +.PHONY: install.wire +install.wire: + @$(GO) install github.com/google/wire/cmd/wire@$(WIRE_VERSION) -## install.gotests: Install gotests, used to generate test functions -.PHONY: install.gotests -install.gotests: - @$(GO) install github.com/cweill/gotests/gotests@latest ## install.protoc-gen-go: Install protoc-gen-go, used to generate go source files from protobuf files .PHONY: install.protoc-gen-go install.protoc-gen-go: - @$(GO) install github.com/golang/protobuf/protoc-gen-go@latest + @$(GO) install github.com/golang/protobuf/protoc-gen-go@$(PROTOC_GEN_GO_VERSION) ## install.cfssl: Install cfssl, used to generate certificates .PHONY: install.cfssl @@ -210,43 +230,49 @@ install.cfssl: ## install.depth: Install depth, used to check dependency tree .PHONY: install.depth install.depth: - @$(GO) install github.com/KyleBanks/depth/cmd/depth@latest + @$(GO) install github.com/KyleBanks/depth/cmd/depth@$(DEPTH_VERSION) ## install.go-callvis: Install go-callvis, used to visualize call graph .PHONY: install.go-callvis install.go-callvis: - @$(GO) install github.com/ofabry/go-callvis@latest + @$(GO) install github.com/ofabry/go-callvis@$(GO_CALLVIS_VERSION) -## install.misspell +## install.misspell: Install misspell .PHONY: install.misspell install.misspell: - @$(GO) install github.com/client9/misspell/cmd/misspell@latest + @$(GO) install github.com/client9/misspell/cmd/misspell@$(MISSPELL_VERSION) ## install.gothanks: Install gothanks, used to thank go dependencies .PHONY: install.gothanks install.gothanks: - @$(GO) install github.com/psampaz/gothanks@latest + @$(GO) install github.com/psampaz/gothanks@$(GOTHANKS_VERSION) ## install.richgo: Install richgo .PHONY: install.richgo install.richgo: - @$(GO) install github.com/kyoh86/richgo@latest + @$(GO) install github.com/kyoh86/richgo@$(RICHGO_VERSION) ## install.rts: Install rts .PHONY: install.rts install.rts: - @$(GO) install github.com/galeone/rts/cmd/rts@latest + @$(GO) install github.com/galeone/rts/cmd/rts@$(RTS_VERSION) # ================= kubecub openim tools ========================================= -## install.typecheck: install kubecub typecheck check for go code +# https://github.com/kubecub +## install.typecheck: Install kubecub typecheck, checks for go code .PHONY: install.typecheck install.typecheck: - @$(GO) install github.com/kubecub/typecheck@latest + @$(GO) install github.com/kubecub/typecheck@$(TYPECHECK_VERSION) -## install.comment-lang-detector: install kubecub comment-lang-detector check for go code comment language +## install.comment-lang-detector: Install kubecub comment-lang-detector, checks for go code comment language .PHONY: install.comment-lang-detector install.comment-lang-detector: - @$(GO) install github.com/kubecub/comment-lang-detector/cmd/cld@latest + @$(GO) install github.com/kubecub/comment-lang-detector/cmd/cld@$(COMMENT_LANG_DETECTOR_VERSION) + +## install.standardizer: Install kubecub standardizer, checks for go code standardization +.PHONY: install.standardizer +install.standardizer: + @$(GO) install github.com/kubecub/standardizer@$(STANDARDIZER_VERSION) ## tools.help: Display help information about the tools package .PHONY: tools.help diff --git a/scripts/verify-standardizer.sh b/scripts/verify-standardizer.sh new file mode 100755 index 000000000..08a13b9a2 --- /dev/null +++ b/scripts/verify-standardizer.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Copyright © 2023 OpenIM. 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. + +# This script does a fast type check of script srnetes code for all platforms. +# Usage: `scripts/verify-standardizer.sh`. + +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +source "${OPENIM_ROOT}/scripts/lib/init.sh" + +openim::golang::verify_go_version + +cd "${OPENIM_ROOT}" +ret=0 +scripts/run-in-gopath.sh \ +make tools.verify.standardizer +${OPENIM_ROOT}/_output/tools/standardizer || ret=$? +if [[ $ret -ne 0 ]]; then + openim::log::error "Failed to check the directory name or file name. Your name may not meet the specification. Please check the configuration file and the directory or file name." >&2 + openim::log::error "Please see https://github.com/kubecub/standardizer for more information." >&2 + exit 1 +fi diff --git a/test/testdata/requests/sendMessage.json b/test/testdata/requests/send-message.json similarity index 100% rename from test/testdata/requests/sendMessage.json rename to test/testdata/requests/send-message.json diff --git a/tools/formitychecker/README.md b/tools/formitychecker/README.md deleted file mode 100644 index 7cabf8a66..000000000 --- a/tools/formitychecker/README.md +++ /dev/null @@ -1,102 +0,0 @@ -# Development of a Go-Based Conformity Checker for Project File and Directory Naming Standards - -### 1. Project Overview - -#### Project Name - -- `GoConformityChecker` - -#### Functionality Description - -- Checks if the file and subdirectory names in a specified directory adhere to specific naming conventions. -- Supports specific file types (e.g., `.go`, `.yml`, `.yaml`, `.md`, `.sh`, etc.). -- Allows users to specify directories to be checked and directories to be ignored. -- More read https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/code-conventions.md - -#### Naming Conventions - -- Go files: Only underscores are allowed. -- YAML, YML, and Markdown files: Only hyphens are allowed. -- Directories: Only underscores are allowed. - -### 2. File Structure - -- `main.go`: Entry point of the program, handles command-line arguments. -- `checker/checker.go`: Contains the core logic. -- `config/config.go`: Parses and stores configuration information. - -### 3. Core Code Design - -#### main.go - -- Parses command-line arguments, including the directory to be checked and directories to be ignored. -- Calls the `checker` module for checking. - -#### config.go - -- Defines a configuration structure, such as directories to check and ignore. - -#### checker.go - -- Iterates through the specified directory. -- Applies different naming rules based on file types and directory names. -- Records files or directories that do not conform to the standards. - -### 4. Pseudocode Example - -#### main.go - -```go -package main - -import ( - "flag" - "fmt" - "GoConformityChecker/checker" -) - -func main() { - // Parse command-line arguments - var targetDir string - var ignoreDirs string - flag.StringVar(&targetDir, "target", ".", "Directory to check") - flag.StringVar(&ignoreDirs, "ignore", "", "Directories to ignore") - flag.Parse() - - // Call the checker - err := checker.CheckDirectory(targetDir, ignoreDirs) - if err != nil { - fmt.Println("Error:", err) - } -} -``` - -#### checker.go - -```go -package checker - -import ( - // Import necessary packages -) - -func CheckDirectory(targetDir, ignoreDirs string) error { - // Iterate through the directory, applying rules to check file and directory names - // Return any found errors or non-conformities - return nil -} -``` - -### 5. Implementation Details - -- **File and Directory Traversal**: Use Go's `path/filepath` package to traverse directories and subdirectories. -- **Naming Rules Checking**: Apply different regex expressions for naming checks based on file extensions. -- **Error Handling and Reporting**: Record files or directories that do not conform and report to the user. - -### 6. Future Development and Extensions - -- Support more file types and naming rules. -- Provide more detailed error reports, such as showing line numbers and specific naming mistakes. -- Add a graphical or web interface for non-command-line users. - -The above is an overview of the entire project's design. Following this design, specific coding implementation can begin. Note that the actual implementation may need adjustments based on real-world conditions. \ No newline at end of file diff --git a/tools/formitychecker/checker/checker.go b/tools/formitychecker/checker/checker.go deleted file mode 100644 index b17cc5427..000000000 --- a/tools/formitychecker/checker/checker.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright © 2024 OpenIM. 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 checker - -import ( - "fmt" - "os" - "path/filepath" - "regexp" - "strings" - - "github.com/OpenIMSDK/tools/errs" - - "github.com/openimsdk/open-im-server/tools/formitychecker/config" -) - -var ( - underscoreRegex = regexp.MustCompile(`^[a-zA-Z0-9_]+\.[a-zA-Z0-9]+$`) - hyphenRegex = regexp.MustCompile(`^[a-zA-Z0-9\-]+\.[a-zA-Z0-9]+$`) -) - -// CheckDirectory initiates the checking process for the specified directories using configuration from config.Config. -func CheckDirectory(cfg *config.Config) error { - ignoreMap := make(map[string]struct{}) - for _, dir := range cfg.IgnoreDirs { - ignoreMap[dir] = struct{}{} - } - - for _, targetDir := range cfg.TargetDirs { - err := filepath.Walk(targetDir, func(path string, info os.FileInfo, err error) error { - if err != nil { - return errs.Wrap(err, fmt.Sprintf("error walking directory '%s'", targetDir)) - } - - // Skip if the directory is in the ignore list - dirName := filepath.Base(filepath.Dir(path)) - if _, ok := ignoreMap[dirName]; ok && info.IsDir() { - return filepath.SkipDir - } - - // Check the naming convention - if err := checkNamingConvention(path, info); err != nil { - fmt.Println(err) - } - - return nil - }) - - if err != nil { - return fmt.Errorf("error checking directory '%s': %w", targetDir, err) - } - } - - return nil -} - -// checkNamingConvention checks if the file or directory name conforms to the standard naming conventions. -func checkNamingConvention(path string, info os.FileInfo) error { - fileName := info.Name() - - // Handle special cases for directories like .git - if info.IsDir() && strings.HasPrefix(fileName, ".") { - return nil // Skip special directories - } - - // Extract the main part of the name (without extension for files) - mainName := fileName - if !info.IsDir() { - mainName = strings.TrimSuffix(fileName, filepath.Ext(fileName)) - } - - // Determine the type of file and apply corresponding naming rule - switch { - case info.IsDir(): - if !isValidName(mainName, "_") { // Directory names must only contain underscores - return fmt.Errorf("!!! invalid directory name: %s", path) - } - case strings.HasSuffix(fileName, ".go"): - if !isValidName(mainName, "_") { // Go files must only contain underscores - return fmt.Errorf("!!! invalid Go file name: %s", path) - } - case strings.HasSuffix(fileName, ".yml"), strings.HasSuffix(fileName, ".yaml"), strings.HasSuffix(fileName, ".md"): - if !isValidName(mainName, "-") { // YML, YAML, and Markdown files must only contain hyphens - return fmt.Errorf("!!! invalid file name: %s", path) - } - } - - return nil -} - -// isValidName checks if the file name conforms to the specified rule (underscore or hyphen). -func isValidName(name, charType string) bool { - switch charType { - case "_": - return underscoreRegex.MatchString(name) - case "-": - return hyphenRegex.MatchString(name) - default: - return false - } -} diff --git a/tools/formitychecker/config/config.go b/tools/formitychecker/config/config.go deleted file mode 100644 index 0c4f6a16b..000000000 --- a/tools/formitychecker/config/config.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright © 2024 OpenIM. 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 config - -import ( - "strings" -) - -// Config holds all the configuration parameters for the checker. -type Config struct { - TargetDirs []string // Directories to check - IgnoreDirs []string // Directories to ignore -} - -// NewConfig creates and returns a new Config instance. -func NewConfig(targetDirs, ignoreDirs string) *Config { - return &Config{ - TargetDirs: parseDirs(targetDirs), - IgnoreDirs: parseDirs(ignoreDirs), - } -} - -// parseDirs splits a comma-separated string into a slice of directory names. -func parseDirs(dirs string) []string { - if dirs == "" { - return nil - } - return strings.Split(dirs, ",") -} diff --git a/tools/formitychecker/formitychecker.go b/tools/formitychecker/formitychecker.go deleted file mode 100644 index 2bedbfb32..000000000 --- a/tools/formitychecker/formitychecker.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright © 2024 OpenIM. 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 main - -import ( - "flag" - "fmt" - - "github.com/openimsdk/open-im-server/tools/formitychecker/checker" - "github.com/openimsdk/open-im-server/tools/formitychecker/config" -) - -func main() { - defaultTargetDirs := "." - defaultIgnoreDirs := "components,.git" - - var targetDirs string - var ignoreDirs string - flag.StringVar(&targetDirs, "target", defaultTargetDirs, "Directories to check (default: current directory)") - flag.StringVar(&ignoreDirs, "ignore", defaultIgnoreDirs, "Directories to ignore (default: A/, B/)") - flag.Parse() - - conf := config.NewConfig(targetDirs, ignoreDirs) - - err := checker.CheckDirectory(conf) - if err != nil { - fmt.Println("Error:", err) - } -} diff --git a/tools/formitychecker/go.mod b/tools/formitychecker/go.mod deleted file mode 100644 index 698b77647..000000000 --- a/tools/formitychecker/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/openimsdk/open-im-server/tools/formitychecker - -go 1.19 From db6313bb92abe5aa657dcc8a886af6fac10214d0 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 14:43:27 +0800 Subject: [PATCH 03/86] Script Refactoring --- scripts-new/start.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 92f86c91d..0b3f9e5d3 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -2,10 +2,8 @@ #!/usr/bin/env bash -OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. OPENIM_SCRIPTS=$(dirname "${BASH_SOURCE[0]}")/ -source "$OPENIM_SCRIPTS/lib/path.sh" -source "$OPENIM_SCRIPTS/define/binaries.sh" +source "$OPENIM_SCRIPTS/bricks.sh" # Assuming 'openim::util::host_platform' is defined in one of the sourced scripts or elsewhere. From e07dc0dd9b9b13e307ccaccf3e1825f7bf5810bc Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 14:44:18 +0800 Subject: [PATCH 04/86] Script Refactoring --- scripts-new/bricks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index efdb3321b..3bb6a6e9b 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -7,7 +7,7 @@ source "${OPENIM_ROOT}/lib/path.sh" #停止所有的二进制对应的进程 -stop_binaries{ +stop_binaries() { for binary in "${!binaries[@]}"; do full_path=$(get_bin_full_path "$binary") openim::util::kill_exist_binary "$full_path" From 7b79deab5c7f71e65b72ac0c9cc290e11033aaa1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 14:45:14 +0800 Subject: [PATCH 05/86] Script Refactoring --- scripts-new/bricks.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 3bb6a6e9b..7bab4170b 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -38,6 +38,7 @@ kill_exist_binaries(){ full_path=$(get_bin_full_path "$binary") result=$(openim::util::kill_exist_binary "$full_path" | tail -n1) if [ "$result" -eq 0 ]; then + ehco "ttttttttttttt" else echo "$full_path running. waiting stop" fi From 86c291c9df99014a1191b173f97f962a2be25df3 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 14:45:26 +0800 Subject: [PATCH 06/86] Script Refactoring --- scripts-new/bricks.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 7bab4170b..1100395d4 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -37,11 +37,6 @@ kill_exist_binaries(){ for binary in "${!binaries[@]}"; do full_path=$(get_bin_full_path "$binary") result=$(openim::util::kill_exist_binary "$full_path" | tail -n1) - if [ "$result" -eq 0 ]; then - ehco "ttttttttttttt" - else - echo "$full_path running. waiting stop" - fi done } From 996d7fea72ba8c466dc9a656aeb43edb8f8bd66d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 14:46:46 +0800 Subject: [PATCH 07/86] Script Refactoring --- scripts-new/bricks.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 1100395d4..d06495360 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -67,7 +67,7 @@ check_binaries_stop() { #检查所有的二进制是否运行 -check_binaries_running{ +check_binaries_running(){ for binary in "${!binaries[@]}"; do expected_count=${binaries[$binary]} full_path=$(get_bin_full_path "$binary") @@ -87,7 +87,7 @@ check_binaries_running{ #打印所有的二进制对应的进程所所监听的端口 -print_listened_ports_by_binaries{ +print_listened_ports_by_binaries(){ for binary in "${!binaries[@]}"; do expected_count=${binaries[$binary]} base_path=$(get_bin_full_path "$binary") From 6891a1edd5229ff8714729a1bb764ac919ab5a98 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 14:49:18 +0800 Subject: [PATCH 08/86] Script Refactoring --- scripts-new/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 0b3f9e5d3..81335969a 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -28,9 +28,9 @@ fi # Call the main function -start_binaries +result=$(start_binaries) -check_binaries_running +return=$(check_binaries_running) print_listened_ports_by_binaries From d41a2b4b992782bfa7b482769f67f6b39e68a4ba Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 14:50:13 +0800 Subject: [PATCH 09/86] Script Refactoring --- scripts-new/start.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 81335969a..041e34516 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -30,7 +30,15 @@ fi # Call the main function result=$(start_binaries) -return=$(check_binaries_running) + +result=$(check_binaries_running) +ret_val=$? +if [ $ret_val -eq 0 ]; then + echo "All binaries are running." +else + echo "$result" +fi + print_listened_ports_by_binaries From eb530a908c7021103f98267d2d0e472e85812ec1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 14:51:56 +0800 Subject: [PATCH 10/86] Script Refactoring --- scripts-new/start.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 041e34516..562cbb2c9 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -18,12 +18,10 @@ kill_exist_binaries result=$(check_binaries_stop) ret_val=$? -if [ $ret_val -eq 0 ]; then - echo "All binaries are stopped." -else - echo "$result" - echo "abort..." - exit 1 +if [ $ret_val -ne 0 ]; then + echo "$result" + echo "abort..." + exit 1 fi From 604c8e142cf4b6776710df95fbb197153033d513 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 14:53:42 +0800 Subject: [PATCH 11/86] Script Refactoring --- scripts-new/check.sh | 16 +++++++++++----- scripts-new/start.sh | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts-new/check.sh b/scripts-new/check.sh index 8e6d06130..3b82cd154 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -24,20 +24,26 @@ -OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/ -source "${OPENIM_ROOT}/lib/util.sh" -source "${OPENIM_ROOT}/define/binaries.sh" -source "${OPENIM_ROOT}/lib/path.sh" +OPENIM_SCRIPTS=$(dirname "${BASH_SOURCE[0]}")/ +source "$OPENIM_SCRIPTS/bricks.sh" +# Call the main function +result=$(start_binaries) + result=$(check_binaries_running) ret_val=$? - if [ $ret_val -eq 0 ]; then echo "All binaries are running." else echo "$result" + echo "abort..." + exit 1 fi + +print_listened_ports_by_binaries + + diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 562cbb2c9..7a2d27404 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -35,6 +35,8 @@ if [ $ret_val -eq 0 ]; then echo "All binaries are running." else echo "$result" + echo "abort..." + exit 1 fi From 61b4d3bd46100660460ae80f17bb40001afa2943 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:09:06 +0800 Subject: [PATCH 12/86] Script Refactoring --- scripts-new/bricks.sh | 17 ++- scripts-new/check.sh | 4 - scripts-new/lib/util.sh | 306 +--------------------------------------- 3 files changed, 16 insertions(+), 311 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index d06495360..1b5d6fc7d 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -68,19 +68,26 @@ check_binaries_stop() { #检查所有的二进制是否运行 check_binaries_running(){ + local no_running_binaries=0 for binary in "${!binaries[@]}"; do expected_count=${binaries[$binary]} full_path=$(get_bin_full_path "$binary") result=$(openim::util::check_process_names "$full_path" "$expected_count") - if [ "$result" -eq 0 ]; then - echo "$binary is running normally." - return 0 + ret_val=$? + if [ "$ret_val" -eq 0 ]; then + echo "$binary is running normally." else - echo "$binary is not running normally, $result processes missing." - return 1 + no_running_binaries=$((no_running_binaries + 1)) + echo $result fi done + + if [ "$no_running_binaries" -ne 0 ]; then + return 1 + else + return 0 + fi } diff --git a/scripts-new/check.sh b/scripts-new/check.sh index 3b82cd154..256293023 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -29,10 +29,6 @@ source "$OPENIM_SCRIPTS/bricks.sh" -# Call the main function -result=$(start_binaries) - - result=$(check_binaries_running) ret_val=$? if [ $ret_val -eq 0 ]; then diff --git a/scripts-new/lib/util.sh b/scripts-new/lib/util.sh index 6d4448d52..b2edb758b 100644 --- a/scripts-new/lib/util.sh +++ b/scripts-new/lib/util.sh @@ -375,13 +375,7 @@ openim::util::check_ports() { # openim::util::check_ports 10002 1004 12345 13306 # -# The `openim::util::check_process_names` function analyzes the state of processes based on given names. -# It accepts multiple process names as arguments and prints: -# 1. The state of the process (whether it's running or not). -# 2. The start time of the process if it's running. -# User: -# openim::util::check_process_names nginx mysql redis -# The function returns a status of 1 if any of the processes is not running. + openim::util::check_process_names() { local process_path="$1" @@ -391,9 +385,10 @@ openim::util::check_process_names() { local running_count=$(ps -ef | grep "$process_path" | grep -v grep | wc -l) if [ "$running_count" -eq "$expected_count" ]; then - echo 0 + return 0 else - echo $(($expected_count - $running_count)) + echo "$process_path Expected $expected_count processes, but $running_count are present" + return 1 fi } @@ -414,94 +409,7 @@ openim::util::check_process_names_exist() { -openim::util::check_process_names_for_stop() { - # Function to get the port of a process - get_port() { - local pid=$1 - if [[ "$OSTYPE" == "linux-gnu"* ]]; then - # Linux - ss -ltnp 2>/dev/null | grep $pid | awk '{print $4}' | cut -d ':' -f2 - elif [[ "$OSTYPE" == "darwin"* ]]; then - # macOS - lsof -nP -iTCP -sTCP:LISTEN -a -p $pid | awk 'NR>1 {print $9}' | sed 's/.*://' - else - echo "Unsupported OS" - return 1 - fi - } - - # Arrays to collect details of processes - local not_started=() - local started=() - - - # Iterate over each given process name - for process_name in "$@"; do - # Use `pgrep` to find process IDs related to the given process name - local pids=($(pgrep -f $process_name)) - - # Check if any process IDs were found - if [[ ${#pids[@]} -eq 0 ]]; then - not_started+=($process_name) - else - # If there are PIDs, loop through each one - for pid in "${pids[@]}"; do - local command=$(ps -p $pid -o comm=) - local start_time=$(ps -p $pid -o lstart=) - local port=$(get_port $pid) - - # Check if port information was found for the PID - if [[ -z $port ]]; then - port="N/A" - fi - - started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time") - done - fi - done - - - if [[ ${#started[@]} -ne 0 ]]; then - echo - echo "The programs that have not exited are:" - for info in "${started[@]}"; do - echo "$info " - done - return 1 - fi - - return 0 - -} - -# openim::util::check_process_names docker-pr - -# The `openim::util::stop_services_on_ports` function stops services running on specified ports. -# It accepts multiple ports as arguments and performs the following: -# 1. Attempts to stop any services running on the specified ports. -# 2. Prints details of services successfully stopped and those that failed to stop. -# Usage: -# openim::util::stop_services_on_ports 8080 8081 8082 -# The function returns a status of 1 if any service couldn't be stopped. - -# nc -l -p 12345 -# nc -l -p 123456 -# ps -ef | grep "nc -l" -# openim::util::stop_services_on_ports 1234 12345 - -# The `openim::util::stop_services_with_name` function stops services with specified names. -# It accepts multiple service names as arguments and performs the following: -# 1. Attempts to stop any services with the specified names. -# 2. Prints details of services successfully stopped and those that failed to stop. -# Usage: -# openim::util::stop_services_with_name nginx apache -# The function returns a status of 1 if any service couldn't be stopped. - -# sleep 333333& -# sleep 444444& -# ps -ef | grep "sleep" -# openim::util::stop_services_with_name "sleep 333333" "sleep 444444" # This figures out the host platform without relying on golang. We need this as # we don't want a golang install to be a prerequisite to building yet we need @@ -1513,151 +1421,6 @@ openim::util::check_ports() { # openim::util::check_ports 10002 1004 12345 13306 # -# The `openim::util::check_process_names` function analyzes the state of processes based on given names. -# It accepts multiple process names as arguments and prints: -# 1. The state of the process (whether it's running or not). -# 2. The start time of the process if it's running. -# User: -# openim::util::check_process_names nginx mysql redis -# The function returns a status of 1 if any of the processes is not running. -openim::util::check_process_names() { - # Function to get the port of a process - get_port() { - local pid=$1 - if [[ "$OSTYPE" == "linux-gnu"* ]]; then - # Linux - ss -ltnp 2>/dev/null | grep $pid | awk '{print $4}' | cut -d ':' -f2 - elif [[ "$OSTYPE" == "darwin"* ]]; then - # macOS - lsof -nP -iTCP -sTCP:LISTEN -a -p $pid | awk 'NR>1 {print $9}' | sed 's/.*://' - else - echo "Unsupported OS" - return 1 - fi - } - - # Arrays to collect details of processes - local not_started=() - local started=() - - echo "Checking processes: $*" - # Iterate over each given process name - for process_name in "$@"; do - # Use `pgrep` to find process IDs related to the given process name - local pids=($(pgrep -f $process_name)) - - # Check if any process IDs were found - if [[ ${#pids[@]} -eq 0 ]]; then - not_started+=($process_name) - else - # If there are PIDs, loop through each one - for pid in "${pids[@]}"; do - local command=$(ps -p $pid -o cmd=) - local start_time=$(ps -p $pid -o lstart=) - local port=$(get_port $pid) - - # Check if port information was found for the PID - if [[ -z $port ]]; then - port="N/A" - fi - - started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time") - done - fi - done - - # Print information - if [[ ${#not_started[@]} -ne 0 ]]; then - echo "Not started processes:" - for process_name in "${not_started[@]}"; do - openim::log::error "Process $process_name is not started." - done - fi - - if [[ ${#started[@]} -ne 0 ]]; then - echo - echo "Started processes:" - for info in "${started[@]}"; do - echo "$info" - done - fi - - # Return status - if [[ ${#not_started[@]} -ne 0 ]]; then - openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}" - openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" - cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' - return 1 - else - echo "" - openim::log::success "All processes are running." - return 0 - fi -} - -# openim::util::check_process_names docker-pr - -# The `openim::util::stop_services_on_ports` function stops services running on specified ports. -# It accepts multiple ports as arguments and performs the following: -# 1. Attempts to stop any services running on the specified ports. -# 2. Prints details of services successfully stopped and those that failed to stop. -# Usage: -# openim::util::stop_services_on_ports 8080 8081 8082 -# The function returns a status of 1 if any service couldn't be stopped. -openim::util::stop_services_on_ports() { - # An array to collect ports of processes that couldn't be stopped. - local not_stopped=() - - # An array to collect information about processes that were stopped. - local stopped=() - - echo "Stopping services on ports: $*" - # Iterate over each given port. - for port in "$@"; do - # Use the `lsof` command to find process information related to the given port. - info=$(lsof -i :$port -n -P | grep LISTEN || true) - - # If there's process information, it means the process associated with the port is running. - if [[ -n $info ]]; then - # Extract the Process ID. - while read -r line; do - local pid=$(echo $line | awk '{print $2}') - - # Try to stop the service by killing its process. - if kill -10 $pid; then - stopped+=($port) - else - not_stopped+=($port) - fi - done <<< "$info" - fi - done - - # Print information about ports whose processes couldn't be stopped. - if [[ ${#not_stopped[@]} -ne 0 ]]; then - echo "Ports that couldn't be stopped:" - for port in "${not_stopped[@]}"; do - openim::log::status "Failed to stop service on port $port." - done - fi - - # Print information about ports whose processes were successfully stopped. - if [[ ${#stopped[@]} -ne 0 ]]; then - for port in "${stopped[@]}"; do - echo "Successfully stopped service on port $port." - done - fi - - # If any of the processes couldn't be stopped, return a status of 1. - if [[ ${#not_stopped[@]} -ne 0 ]]; then - return 1 - else - openim::log::success "All specified services were stopped." - echo "" - return 0 - fi -} - # The `openim::util::stop_services_with_name` function stops services with specified names. # It accepts multiple service names as arguments and performs the following: @@ -2672,69 +2435,8 @@ function openim::util::is_running_in_container() { } -function openim::util::check_process_names_for_stop() { - local all_stopped=true - for service in "${OPENIM_ALL_SERVICE_LIBRARIES[@]}"; do - - PIDS=$(pgrep -f "${service}") || PIDS="0" - if [ "$PIDS" = "0" ]; then - continue - fi - NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs) - if [ "$NUM_PROCESSES" -gt 0 ]; then - all_stopped=false - echo "Found $NUM_PROCESSES processes for ${service}" - for PID in $PIDS; do - if [[ "$OSTYPE" == "linux-gnu"* ]]; then - echo -e "\033[31m$(ps -p $PID -o pid,cmd)\033[0m" - elif [[ "$OSTYPE" == "darwin"* ]]; then - echo -e "\033[31m$(ps -p $PID -o pid,comm)\033[0m" - else - openim::log::error "Unsupported OS type: $OSTYPE" - fi - done - echo "Processes for ${service} have not been stopped properly. " "$NUM_PROCESSES" - fi - done - - if [ "$all_stopped" = true ]; then - openim::log::success "All processes have been stopped properly." - return 0 - fi - - return 1 -} - - - - -function openim::util::find_process_ports() { - local process_path="$1" - if [[ -z "$process_path" ]]; then - echo "Usage: find_process_ports /path/to/process" - return 1 - fi - - local protocol_ports="" - while read -r line; do - local port_protocol=($line) - local port=${port_protocol[0]##*:} - local protocol=${port_protocol[1]} - protocol_ports="${protocol_ports}${protocol} ${port}, " - - done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}') - - protocol_ports=${protocol_ports%, } - - if [[ -z "$protocol_ports" ]]; then - openim::log::colorless "$process_path is not listening on any ports" - else - openim::log::colorless "$process_path is listening on protocol & port: $protocol_ports" - fi -} - From 1b45539b77a9f031d50e6f209d7255966a35ecfc Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:10:28 +0800 Subject: [PATCH 13/86] Script Refactoring --- scripts-new/stop.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts-new/stop.sh b/scripts-new/stop.sh index 80ad52f5d..2e222c4a4 100644 --- a/scripts-new/stop.sh +++ b/scripts-new/stop.sh @@ -3,12 +3,20 @@ -OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/ -source "${OPENIM_ROOT}/lib/util.sh" -source "${OPENIM_ROOT}/define/binaries.sh" -source "${OPENIM_ROOT}/lib/path.sh" +OPENIM_SCRIPTS=$(dirname "${BASH_SOURCE[0]}")/ +source "$OPENIM_SCRIPTS/bricks.sh" +kill_exist_binaries + +result=$(check_binaries_stop) +ret_val=$? + +if [ $ret_val -ne 0 ]; then + echo "$result" + echo "no stop..." + exit 1 +fi From d9adcc50bff35005a8728cc4437c21eec6c10e83 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:16:02 +0800 Subject: [PATCH 14/86] Script Refactoring --- cmd/openim-no-port/main.go | 19 +++++++++++++++++++ scripts-new/stop.sh | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 cmd/openim-no-port/main.go diff --git a/cmd/openim-no-port/main.go b/cmd/openim-no-port/main.go new file mode 100644 index 000000000..f0f428ff6 --- /dev/null +++ b/cmd/openim-no-port/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "flag" + "fmt" + "time" +) + +func main() { + // Define flags + index := flag.Int("i", 0, "Index number") + config := flag.String("c", "", "Configuration path") + + // Parse the flags + flag.Parse() + // Print the values of the flags + fmt.Printf("args: -i %d -c %s\n", *index, *config) + time.Sleep(500 * time.Second) +} diff --git a/scripts-new/stop.sh b/scripts-new/stop.sh index 2e222c4a4..2ea534525 100644 --- a/scripts-new/stop.sh +++ b/scripts-new/stop.sh @@ -20,3 +20,5 @@ if [ $ret_val -ne 0 ]; then echo "no stop..." exit 1 fi + +echo "all stop" \ No newline at end of file From 8c1d71ee96ea1bee4d84b594f63aeecd627ac4a0 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:17:50 +0800 Subject: [PATCH 15/86] Script Refactoring --- cmd/openim-no-port/main.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/cmd/openim-no-port/main.go b/cmd/openim-no-port/main.go index f0f428ff6..7c63c8839 100644 --- a/cmd/openim-no-port/main.go +++ b/cmd/openim-no-port/main.go @@ -3,17 +3,43 @@ package main import ( "flag" "fmt" + "math/rand" + "os" "time" ) +package main + +import ( +"flag" +"fmt" +"math/rand" +"os" +"time" +) + func main() { + // Initialize the random seed + rand.Seed(time.Now().UnixNano()) + // Define flags index := flag.Int("i", 0, "Index number") config := flag.String("c", "", "Configuration path") // Parse the flags flag.Parse() + // Print the values of the flags fmt.Printf("args: -i %d -c %s\n", *index, *config) - time.Sleep(500 * time.Second) + + // Generate a random number (0 or 1) and subtract 1 to get 0 or -1 + randomValue := rand.Intn(2) - 1 + + if randomValue == 0 { + fmt.Println("Sleeping for 500 seconds...") + time.Sleep(500 * time.Second) + } else if randomValue == -1 { + fmt.Fprintln(os.Stderr, "An error occurred. Exiting with status -1.") + os.Exit(-1) + } } From b461aa249b0d89ddd5c7d4e0af17a9aa60d90754 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:18:59 +0800 Subject: [PATCH 16/86] Script Refactoring --- scripts-new/define/binaries.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts-new/define/binaries.sh b/scripts-new/define/binaries.sh index 0c6fa524c..9a8ca4a76 100644 --- a/scripts-new/define/binaries.sh +++ b/scripts-new/define/binaries.sh @@ -4,5 +4,6 @@ # The count for openim-msgtransfer is set to 4, all others are set to 1. declare -A binaries=( [openim-test]=2 + [openim-no-port]=2 ) From a1ff129c0ffab1cd100af6312e739d8cfbaa263b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:19:57 +0800 Subject: [PATCH 17/86] Script Refactoring --- cmd/openim-no-port/main.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cmd/openim-no-port/main.go b/cmd/openim-no-port/main.go index 7c63c8839..349da1f02 100644 --- a/cmd/openim-no-port/main.go +++ b/cmd/openim-no-port/main.go @@ -8,16 +8,6 @@ import ( "time" ) -package main - -import ( -"flag" -"fmt" -"math/rand" -"os" -"time" -) - func main() { // Initialize the random seed rand.Seed(time.Now().UnixNano()) From e4f95e40297af5575efc5c2e808ecca1d85bce3d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:22:46 +0800 Subject: [PATCH 18/86] Script Refactoring --- scripts-new/bricks.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 1b5d6fc7d..dc100eac3 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -25,7 +25,9 @@ start_binaries() { # Loop to start binary the specified number of times for ((i=0; i "test.log" 2>&1 & + #nohup "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > "test.log" 2>&1 & + { nohup "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > >(tee test.log) 2> >(tee test.err >&2) & } + done done From aa516f1684bd28096e87697b7ea383013b53c759 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:25:11 +0800 Subject: [PATCH 19/86] Script Refactoring --- scripts-new/bricks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index dc100eac3..b3ffb10b6 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -26,7 +26,7 @@ start_binaries() { for ((i=0; i "test.log" 2>&1 & - { nohup "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > >(tee test.log) 2> >(tee test.err >&2) & } + nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & done From a932db69221cb670657efaa02f6a240329e4d4dd Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:28:21 +0800 Subject: [PATCH 20/86] Script Refactoring --- scripts-new/bricks.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index b3ffb10b6..e39d3427e 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -26,7 +26,8 @@ start_binaries() { for ((i=0; i "test.log" 2>&1 & - nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & + #nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & + nohup ./run_my_command.sh "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > test.log 2>&1 & done From 4b7b0afc0ac702548ef0ca1e6bc53516c61496da Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:37:31 +0800 Subject: [PATCH 21/86] Script Refactoring --- scripts-new/bricks.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index e39d3427e..a0820a9eb 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -27,7 +27,8 @@ start_binaries() { echo "Starting $binary instance $i: $bin_full_path -i $i -c $OPENIM_OUTPUT_CONFIG" #nohup "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > "test.log" 2>&1 & #nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & - nohup ./run_my_command.sh "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > test.log 2>&1 & + #nohup ./run_my_command.sh "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > test.log 2>&1 & + nohup "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" & done From 512df7b622d0ca6971e41995e163fe50b101f573 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:43:45 +0800 Subject: [PATCH 22/86] Script Refactoring --- scripts-new/bricks.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index a0820a9eb..8ab187b59 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -28,8 +28,8 @@ start_binaries() { #nohup "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > "test.log" 2>&1 & #nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & #nohup ./run_my_command.sh "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > test.log 2>&1 & - nohup "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" & - + cmd="$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" + nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 & done done From f5a9dccd10b0f9a92b748c10d7a676fb02b1f25d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:44:50 +0800 Subject: [PATCH 23/86] Script Refactoring --- scripts-new/bricks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 8ab187b59..751bfd24e 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -28,7 +28,7 @@ start_binaries() { #nohup "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > "test.log" 2>&1 & #nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & #nohup ./run_my_command.sh "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > test.log 2>&1 & - cmd="$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" + cmd=("$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG") nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 & done From f75450a93a8de22be2d4c63ee9ef57fa209f75b9 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:46:17 +0800 Subject: [PATCH 24/86] Script Refactoring --- scripts-new/bricks.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 751bfd24e..761e1337f 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -14,6 +14,8 @@ stop_binaries() { done } +LOG_FILE=log.file +TMP_LOG_FILE=tmp.log.file #启动所有的二进制 start_binaries() { From 53a0cf0b72080f2cc54a973cf685b76a107eaad5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:50:02 +0800 Subject: [PATCH 25/86] Script Refactoring --- scripts-new/bricks.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 761e1337f..e0bce6609 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -31,7 +31,8 @@ start_binaries() { #nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & #nohup ./run_my_command.sh "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > test.log 2>&1 & cmd=("$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG") - nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 & + nohup "${cmd[@]}" >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & + done done From 54430cea9f8fd64039c760774f7676f969ce7ff1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:55:00 +0800 Subject: [PATCH 26/86] Script Refactoring --- scripts-new/bricks.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index e0bce6609..71c6966b1 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -31,7 +31,8 @@ start_binaries() { #nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & #nohup ./run_my_command.sh "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > test.log 2>&1 & cmd=("$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG") - nohup "${cmd[@]}" >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & + #nohup "${cmd[@]}" >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & + nohup "${cmd[@]}" > >(tee -a "$TMP_LOG_FILE") 2> >(tee -a "$TMP_LOG_FILE" >&2) & done From 57cc797f08d91decca92908938b3e04482583ecc Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 15:56:27 +0800 Subject: [PATCH 27/86] Script Refactoring --- scripts-new/bricks.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 71c6966b1..d2077ec1e 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -15,7 +15,7 @@ stop_binaries() { } LOG_FILE=log.file -TMP_LOG_FILE=tmp.log.file +ERR_LOG_FILE=err.log.file #启动所有的二进制 start_binaries() { @@ -31,10 +31,7 @@ start_binaries() { #nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & #nohup ./run_my_command.sh "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > test.log 2>&1 & cmd=("$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG") - #nohup "${cmd[@]}" >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & - nohup "${cmd[@]}" > >(tee -a "$TMP_LOG_FILE") 2> >(tee -a "$TMP_LOG_FILE" >&2) & - - + nohup "${cmd[@]}" >> "${LOG_FILE}" 2> >(tee -a "$ERR_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & done done } From 92650ab78945384011b49df80e0d6160609ad892 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:01:35 +0800 Subject: [PATCH 28/86] Script Refactoring --- scripts-new/bricks.sh | 3 --- scripts-new/check.sh | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index d2077ec1e..2feae3d89 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -27,9 +27,6 @@ start_binaries() { # Loop to start binary the specified number of times for ((i=0; i "test.log" 2>&1 & - #nohup sh -c '"$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" 2>&1 | tee test.log' & - #nohup ./run_my_command.sh "$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG" > test.log 2>&1 & cmd=("$bin_full_path" -i "$i" -c "$OPENIM_OUTPUT_CONFIG") nohup "${cmd[@]}" >> "${LOG_FILE}" 2> >(tee -a "$ERR_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & done diff --git a/scripts-new/check.sh b/scripts-new/check.sh index 256293023..eb6028aa2 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -32,10 +32,10 @@ source "$OPENIM_SCRIPTS/bricks.sh" result=$(check_binaries_running) ret_val=$? if [ $ret_val -eq 0 ]; then - echo "All binaries are running." + echo "All services are running normally." else + echo "Some services are not running as expected." echo "$result" - echo "abort..." exit 1 fi From 318565acd824992a55b18cff63d93a5277fbaece Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Tue, 2 Apr 2024 11:01:42 +0800 Subject: [PATCH 29/86] feat: optimize config --- pkg/common/db/table/relation/msg.go | 1 + tools/component/component.go | 2 +- tools/component/util/env.go | 107 ---------------------------- 3 files changed, 2 insertions(+), 108 deletions(-) delete mode 100644 tools/component/util/env.go diff --git a/pkg/common/db/table/relation/msg.go b/pkg/common/db/table/relation/msg.go index fcdaf3299..14b8dbb30 100644 --- a/pkg/common/db/table/relation/msg.go +++ b/pkg/common/db/table/relation/msg.go @@ -21,6 +21,7 @@ import ( "github.com/openimsdk/protocol/msg" "github.com/openimsdk/protocol/sdkws" + "github.com/openimsdk/tools/errs" "go.mongodb.org/mongo-driver/mongo" ) diff --git a/tools/component/component.go b/tools/component/component.go index 6cea8352d..a625cdad0 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -115,7 +115,7 @@ func main() { allSuccess := true for _, check := range serviceChecks { - if err := check(ctx, conf); err != nil { + if err := check(ctx, &config.Config); err != nil { util.ColorErrPrint(fmt.Sprintf("Check failed: %v", err)) allSuccess = false break diff --git a/tools/component/util/env.go b/tools/component/util/env.go deleted file mode 100644 index 92f072f76..000000000 --- a/tools/component/util/env.go +++ /dev/null @@ -1,107 +0,0 @@ -package util - -import ( - "os" - "strconv" - "strings" - - "github.com/openimsdk/open-im-server/v3/pkg/common/config" - "github.com/openimsdk/tools/errs" -) - -func ConfigGetEnv(config *config.GlobalConfig) error { - config.Mongo.Uri = getEnv("MONGO_URI", config.Mongo.Uri) - config.Mongo.Username = getEnv("MONGO_OPENIM_USERNAME", config.Mongo.Username) - config.Mongo.Password = getEnv("MONGO_OPENIM_PASSWORD", config.Mongo.Password) - config.Mongo.Address = getArrEnv("MONGO_ADDRESS", "MONGO_PORT", config.Mongo.Address) - config.Mongo.Database = getEnv("MONGO_DATABASE", config.Mongo.Database) - maxPoolSize, err := getEnvInt("MONGO_MAX_POOL_SIZE", config.Mongo.MaxPoolSize) - if err != nil { - return errs.WrapMsg(err, "MONGO_MAX_POOL_SIZE") - } - config.Mongo.MaxPoolSize = maxPoolSize - - config.Redis.Username = getEnv("REDIS_USERNAME", config.Redis.Username) - config.Redis.Password = getEnv("REDIS_PASSWORD", config.Redis.Password) - config.Redis.Address = getArrEnv("REDIS_ADDRESS", "REDIS_PORT", config.Redis.Address) - - config.Object.ApiURL = getEnv("OBJECT_APIURL", config.Object.ApiURL) - config.Object.Minio.Endpoint = getEnv("MINIO_ENDPOINT", config.Object.Minio.Endpoint) - config.Object.Minio.AccessKeyID = getEnv("MINIO_ACCESS_KEY_ID", config.Object.Minio.AccessKeyID) - config.Object.Minio.SecretAccessKey = getEnv("MINIO_SECRET_ACCESS_KEY", config.Object.Minio.SecretAccessKey) - config.Object.Minio.SignEndpoint = getEnv("MINIO_SIGN_ENDPOINT", config.Object.Minio.SignEndpoint) - - config.Zookeeper.Schema = getEnv("ZOOKEEPER_SCHEMA", config.Zookeeper.Schema) - config.Zookeeper.ZkAddr = getArrEnv("ZOOKEEPER_ADDRESS", "ZOOKEEPER_PORT", config.Zookeeper.ZkAddr) - config.Zookeeper.Username = getEnv("ZOOKEEPER_USERNAME", config.Zookeeper.Username) - config.Zookeeper.Password = getEnv("ZOOKEEPER_PASSWORD", config.Zookeeper.Password) - - config.Kafka.Username = getEnv("KAFKA_USERNAME", config.Kafka.Username) - config.Kafka.Password = getEnv("KAFKA_PASSWORD", config.Kafka.Password) - config.Kafka.Addr = getArrEnv("KAFKA_ADDRESS", "KAFKA_PORT", config.Kafka.Addr) - config.Object.Minio.Endpoint = getMinioAddr("MINIO_ENDPOINT", "MINIO_ADDRESS", "MINIO_PORT", config.Object.Minio.Endpoint) - return nil -} - -// Helper function to get environment variable or default value -func getEnv(key, fallback string) string { - if value, exists := os.LookupEnv(key); exists { - return value - } - return fallback -} - -// Helper function to get environment variable or default value -func getEnvInt(key string, fallback int) (int, error) { - if value, exists := os.LookupEnv(key); exists { - val, err := strconv.Atoi(value) - if err != nil { - return 0, errs.WrapMsg(err, "string to int failed") - } - return val, nil - } - return fallback, nil -} - -func getArrEnv(key1, key2 string, fallback []string) []string { - address, addrExists := os.LookupEnv(key1) - port, portExists := os.LookupEnv(key2) - - if addrExists && portExists { - addresses := strings.Split(address, ",") - for i, addr := range addresses { - addresses[i] = addr + ":" + port - } - return addresses - } - - if addrExists && !portExists { - addresses := strings.Split(address, ",") - for i, addr := range addresses { - addresses[i] = addr + ":" + "0" - } - return addresses - } - - if !addrExists && portExists { - result := make([]string, len(fallback)) - for i, addr := range fallback { - add := strings.Split(addr, ":") - result[i] = add[0] + ":" + port - } - return result - } - return fallback -} - -func getMinioAddr(key1, key2, key3, fallback string) string { - // Prioritize environment variables - endpoint := getEnv(key1, fallback) - address, addressExist := os.LookupEnv(key2) - port, portExist := os.LookupEnv(key3) - if portExist && addressExist { - endpoint = "http://" + address + ":" + port - return endpoint - } - return endpoint -} From 655add88bb1fda4428d1b6bbefd110d5d32799c5 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Tue, 2 Apr 2024 15:58:15 +0800 Subject: [PATCH 30/86] feat: add code lint --- pkg/common/discoveryregister/discoveryregister.go | 6 ------ pkg/common/discoveryregister/kubernetes/kubernetes.go | 4 +++- scripts/check-all.sh | 7 ------- scripts/start-all.sh | 1 - 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/pkg/common/discoveryregister/discoveryregister.go b/pkg/common/discoveryregister/discoveryregister.go index fdebd79cc..3ac8710aa 100644 --- a/pkg/common/discoveryregister/discoveryregister.go +++ b/pkg/common/discoveryregister/discoveryregister.go @@ -15,8 +15,6 @@ package discoveryregister import ( - "os" - "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/direct" "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/kubernetes" @@ -28,10 +26,6 @@ import ( // NewDiscoveryRegister creates a new service discovery and registry client based on the provided environment type. func NewDiscoveryRegister(config *config.GlobalConfig) (discovery.SvcDiscoveryRegistry, error) { - if os.Getenv("ENVS_DISCOVERY") != "" { - config.Envs.Discovery = os.Getenv("ENVS_DISCOVERY") - } - switch config.Envs.Discovery { case "zookeeper": return zookeeper.NewZookeeperDiscoveryRegister(&config.Zookeeper) diff --git a/pkg/common/discoveryregister/kubernetes/kubernetes.go b/pkg/common/discoveryregister/kubernetes/kubernetes.go index 302393ed0..78fcd579a 100644 --- a/pkg/common/discoveryregister/kubernetes/kubernetes.go +++ b/pkg/common/discoveryregister/kubernetes/kubernetes.go @@ -104,6 +104,7 @@ func getSelfHost(ctx context.Context, gatewayName string) string { } // like openimserver-openim-msggateway-0.openimserver-openim-msggateway-headless.openim-lin.svc.cluster.local:88. +// Replica set in kubernetes environment func getMsgGatewayHost(ctx context.Context, gatewayName string) []string { port := 88 instance := "openimserver" @@ -189,9 +190,10 @@ func (cli *K8sDR) CloseConn(conn *grpc.ClientConn) { // do not use this method for call rpc. func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn { - fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!") + log.ZError(context.Background(), "should not call this function!", nil) return nil } + func (cli *K8sDR) Close() { } diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 2fc773b2f..54296b22d 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -20,9 +20,6 @@ # READ: https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh - - - OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" @@ -114,7 +111,3 @@ else openim::util::find_ports_for_all_services ${OPENIM_MSGTRANSFER_BINARY[@]} openim::log::success "All OpenIM services are running normally! " fi - - - - diff --git a/scripts/start-all.sh b/scripts/start-all.sh index acc926f59..6f4a6c574 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -94,7 +94,6 @@ if [[ $? -ne 0 ]]; then exit 1 fi - result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then openim::log::error "The OpenIM services may fail to start.\n $result" From 7e7a3d0d2256f85e699110e19ef3ffc79c1549d0 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751NSS@gmail.com> Date: Sun, 31 Mar 2024 12:40:35 +0800 Subject: [PATCH 31/86] docs: update openim images docs deployment aliyun (#2154) --- docs/contrib/images.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/contrib/images.md b/docs/contrib/images.md index d1a83d639..396ffb2e3 100644 --- a/docs/contrib/images.md +++ b/docs/contrib/images.md @@ -96,4 +96,21 @@ When pulling OpenIM's Docker images, you can choose the most suitable source bas 3. Run the `docker images` command to confirm that the image has been successfully pulled. -This concludes OpenIM's image management strategy and the steps for pulling images. If you have any questions, please feel free to ask. +### Accelerating Deployment for Users in China with Aliyun Mirror or Alternative Image Addresses + +For users in China looking to speed up the deployment process of OpenIM, leveraging a mirror image address is a highly recommended practice. After executing the `make init` command, a `.env` file is generated, which you'll need to edit to configure the image registry source. This configuration is crucial for optimizing download speeds and ensuring a smoother setup process. + +Within the generated `.env` file, you'll find a section dedicated to choosing the image address. It includes options for GitHub (`ghcr.io/openimsdk`), Docker Hub (`openim`), and Ali Cloud (`registry.cn-hangzhou.aliyuncs.com/openimsdk`). To achieve the best performance within China, it is advised to use the Aliyun image address. + +To do this, you need to comment out the current `IMAGE_REGISTRY` setting and uncomment the Aliyun option. Here is how you can adjust it for Aliyun: + +```bash +# Choose the image address: GitHub (ghcr.io/openimsdk), Docker Hub (openim), +# or Ali Cloud (registry.cn-hangzhou.aliyuncs.com/openimsdk). +# Uncomment one of the following three options. Aliyun is recommended for users in China. +# IMAGE_REGISTRY="ghcr.io/openimsdk" +# IMAGE_REGISTRY="openim" +IMAGE_REGISTRY="registry.cn-hangzhou.aliyuncs.com/openimsdk" +``` + +This change directs the deployment process to fetch the required images from the Aliyun registry, significantly improving download and installation speeds due to the geographical and network advantages within China. If, for any reason, you prefer not to use Aliyun or encounter issues, consider switching to another mirror address listed in the `.env` file by following the same uncommenting process. This flexibility ensures that users can select the most suitable image source for their specific situation, leading to a more efficient deployment of OpenIM. From 409071344ca4b70aac99f655b85da070c830de88 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Tue, 2 Apr 2024 16:01:45 +0800 Subject: [PATCH 32/86] feat: Enhancements to OpenIM Engineering Practices with Standardizer and Tool Versioning (#2159) * feat: add standardizer optimize makefile * feat: add standardizer optimize makefile * feat: add openim test docs * feat: add openim kafka docs * feat: add openim kafka docs * feat: add openim kafka docs --- .github/code-language-detector.yml | 1 + .github/release-drafter.yml | 2 +- .github/standardizer.yml | 50 ++++++ .github/workflows/openimci.yml | 3 + Makefile | 1 + README_zh_CN.md | 2 +- docker-compose-1.yml | 2 +- docker-compose.yml | 2 +- docs/contrib/kafka.md | 162 ++++++++++++++++++ docs/contrib/logging.md | 2 +- docs/contrib/test.md | 86 +++++++++- docs/images/Open-IM.png | Bin 17614 -> 0 bytes .../{Architecture.jpg => architecture.jpg} | Bin docs/images/{Wechat.jpg => wechat.jpg} | Bin .../{directResolver.go => direct_resolver.go} | 0 scripts/make-rules/common-versions.mk | 58 +++++++ scripts/make-rules/common.mk | 7 + scripts/make-rules/tools.mk | 110 +++++++----- scripts/verify-standardizer.sh | 33 ++++ .../{sendMessage.json => send-message.json} | 0 20 files changed, 471 insertions(+), 50 deletions(-) create mode 100644 .github/standardizer.yml create mode 100644 docs/contrib/kafka.md delete mode 100644 docs/images/Open-IM.png rename docs/images/{Architecture.jpg => architecture.jpg} (100%) rename docs/images/{Wechat.jpg => wechat.jpg} (100%) rename pkg/common/discoveryregister/direct/{directResolver.go => direct_resolver.go} (100%) create mode 100644 scripts/make-rules/common-versions.mk create mode 100755 scripts/verify-standardizer.sh rename test/testdata/requests/{sendMessage.json => send-message.json} (100%) diff --git a/.github/code-language-detector.yml b/.github/code-language-detector.yml index 32a8c1f54..194c2474a 100644 --- a/.github/code-language-detector.yml +++ b/.github/code-language-detector.yml @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +# https://github.com/marketplace/actions/code-language-detector directory: ./ file_types: - .go diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 154386ff5..55ee241d7 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -48,4 +48,4 @@ template: | ## Contributors to this $REPOSITORY release - $CONTRIBUTORS \ No newline at end of file + $CONTRIBUTORS diff --git a/.github/standardizer.yml b/.github/standardizer.yml new file mode 100644 index 000000000..fceb69df1 --- /dev/null +++ b/.github/standardizer.yml @@ -0,0 +1,50 @@ +# https://github.com/marketplace/actions/conformity-checker-for-project +baseConfig: + searchDirectory: "./" + ignoreCase: false + +directoryNaming: + allowHyphens: true + allowUnderscores: false + mustBeLowercase: true + +fileNaming: + allowHyphens: true + allowUnderscores: true + mustBeLowercase: true + +ignoreFormats: + - "\\.log$" + - "\\.env$" + - "README\\.md$" + - "_test\\.go$" + - "\\.md$" + - _test\\.txt$ + - LICENSE + - Dockerfile + - CODEOWNERS + - Makefile + +ignoreDirectories: + - "vendor" + - ".git" + - "deployments" + - "node_modules" + - "logs" + - "CHANGELOG" + - "components" + - "_output" + - "tools/openim-web" + - "CHANGELOG" + - "examples/Test_directory" + - test/testdata + +fileTypeSpecificNaming: + ".yaml": + allowHyphens: true + allowUnderscores: false + mustBeLowercase: true + ".go": + allowHyphens: false + allowUnderscores: true + mustBeLowercase: true \ No newline at end of file diff --git a/.github/workflows/openimci.yml b/.github/workflows/openimci.yml index 5aeddd09a..f47283997 100644 --- a/.github/workflows/openimci.yml +++ b/.github/workflows/openimci.yml @@ -73,6 +73,9 @@ jobs: - name: Code Typecheck Detector uses: kubecub/typecheck@main + - name: Conformity Checker for Project + uses: kubecub/standardizer@main + - name: Module Operations run: | sudo make tidy diff --git a/Makefile b/Makefile index 89b9e4152..818372fb8 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ VERSION_PACKAGE=github.com/openimsdk/open-im-server/v3/pkg/version # Includes include scripts/make-rules/common.mk # make sure include common.mk at the first include line +include scripts/make-rules/common-versions.mk include scripts/make-rules/golang.mk include scripts/make-rules/image.mk include scripts/make-rules/copyright.mk diff --git a/README_zh_CN.md b/README_zh_CN.md index 7eabfa509..f42031165 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -52,7 +52,7 @@

## 🟢 扫描微信进群交流 - + ## Ⓜ️ 关于 OpenIM diff --git a/docker-compose-1.yml b/docker-compose-1.yml index 39fc944ce..ed852fd29 100644 --- a/docker-compose-1.yml +++ b/docker-compose-1.yml @@ -1,4 +1,4 @@ -#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/OpenIMSDK/Open-IM-Server.git +#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/openimsdk/open-im-server.git # The command that triggers this file to pull the image is "docker compose up -f" version: '3' diff --git a/docker-compose.yml b/docker-compose.yml index ef0714329..a983acbaf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/OpenIMSDK/Open-IM-Server.git +#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/openimsdk/open-im-server.git # The command that triggers this file to pull the image is "docker compose up -d". version: '3' diff --git a/docs/contrib/kafka.md b/docs/contrib/kafka.md new file mode 100644 index 000000000..4547c9480 --- /dev/null +++ b/docs/contrib/kafka.md @@ -0,0 +1,162 @@ +# OpenIM Kafka Guide + +This document aims to provide a set of concise guidelines to help you quickly install and use Kafka through Docker Compose. + +## Installing Kafka + +With the Docker Compose script provided by OpenIM, you can easily install Kafka. Use the following command to start Kafka: + +```bash +docker compose up -d +``` + +After executing this command, Kafka will be installed and started. You can confirm the Kafka container is running with the following command: + +```bash +docker ps | grep kafka +``` + +The output of this command, as shown below, displays the status information of the Kafka container: + +``` +be416b5a0851 bitnami/kafka:3.5.1 "/opt/bitnami/script…" 3 days ago Up 2 days 9092/tcp, 0.0.0.0:19094->9094/tcp, :::19094->9094/tcp kafka +``` + +### References + +- Official Docker installation documentation: [Click here](http://events.jianshu.io/p/b60afa35303a) +- Detailed installation guide: [Tutorial on Towards Data Science](https://towardsdatascience.com/how-to-install-apache-kafka-using-docker-the-easy-way-4ceb00817d8b) + +## Using Kafka + +### Entering the Kafka Container + +To execute Kafka commands, you first need to enter the Kafka container. Use the following command: + +```bash +docker exec -it kafka bash +``` + +### Kafka Command Tools + +Inside the Kafka container, you can use various command-line tools to manage Kafka. These tools include but are not limited to: + +- `kafka-topics.sh`: For creating, deleting, listing, or altering topics. +- `kafka-console-producer.sh`: Allows sending messages to a specified topic from the command line. +- `kafka-console-consumer.sh`: Allows reading messages from the command line, with the ability to specify topics. +- `kafka-consumer-groups.sh`: For managing consumer group information. + +### Kafka Client Tool Installation + +For easier Kafka management, you can install Kafka client tools. If you installed Kafka through OpenIM's Docker Compose, you can install the Kafka client tools with the following command: + +```bash +make install.kafkactl +``` + +### Automatic Topic Creation + +When installing Kafka through OpenIM's Docker Compose method, OpenIM automatically creates the following topics: + +- `latestMsgToRedis` +- `msgToPush` +- `offlineMsgToMongoMysql` + +These topics are created using the `scripts/create-topic.sh` script. The script waits for Kafka to be ready before executing the commands to create topics: + +```bash +# Wait for Kafka to be ready +until /opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092; do + echo "Waiting for Kafka to be ready..." + sleep 2 +done + +# Create topics +/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic latestMsgToRedis +/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic msgToPush +/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic offlineMsgToMongoMysql + +echo "Topics created." +``` + +The optimized and expanded documentation further details some basic commands for operations inside the Kafka container, as well as basic commands for managing Kafka using `kafkactl`. Here is a more detailed guide. + + +## Basic Commands in the Kafka Container + +### Listing Topics + +To list all existing topics, you can use the following command: + +```bash +kafka-topics.sh --list --bootstrap-server localhost:9092 +``` + +### Creating a New Topic + +When creating a new topic, you can specify the number of partitions and the replication factor. Here is the command to create a new topic: + +```bash +kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic your_topic_name +``` + +### Producing Messages + +To send messages to a specific topic, you can use the producer command. The following command prompts you to enter messages, which are sent to the specified topic with each press of the Enter key: + +```bash +kafka-console-producer.sh --broker-list localhost:9092 --topic your_topic_name +``` + +### Consuming Messages + +To read messages from a specific topic, you can use the consumer command. The following command reads new messages from the specified topic and outputs them on the console: + +```bash +kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic your_topic_name --from-beginning +``` + +The ` + +--from-beginning` parameter reads messages from the beginning of the topic. If this parameter is omitted, only new messages will be read. + + +## Basic Commands Using `kafkactl` + +`kafkactl` is a command-line tool for managing and operating Kafka clusters. It offers a more modern way to interact with Kafka. + +### Listing Topics + +To list all topics, you can use: + +```bash +kafkactl get topics +``` + +### Creating a New Topic + +To create a new topic with `kafkactl`, use: + +```bash +kafkactl create topic your_topic_name --partitions 1 --replication-factor 1 +``` + +### Producing Messages + +To send messages to a topic, you can use: + +```bash +kafkactl produce your_topic_name --value "your message" +``` + +Here, `"your message"` is the content of the message you want to send. + +### Consuming Messages + +To consume messages from a topic, use: + +```bash +kafkactl consume your_topic_name --from-beginning +``` + +Again, the `--from-beginning` parameter will start consuming messages from the beginning of the topic. If you do not wish to start from the beginning, you can omit this parameter. \ No newline at end of file diff --git a/docs/contrib/logging.md b/docs/contrib/logging.md index e25ac92c2..b88fbeb8d 100644 --- a/docs/contrib/logging.md +++ b/docs/contrib/logging.md @@ -2,7 +2,7 @@ ## Script Logging Documentation Link -If you wish to view the script's logging documentation, you can click on this link: [Logging Documentation](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/contrib/bash-log.md). +If you wish to view the script's logging documentation, you can click on this link: [Logging Documentation](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/bash-log.md). Below is the documentation for logging and error handling in the OpenIM Go project. diff --git a/docs/contrib/test.md b/docs/contrib/test.md index 37c1792cf..2470a0537 100644 --- a/docs/contrib/test.md +++ b/docs/contrib/test.md @@ -2,14 +2,94 @@ This document serves as a comprehensive guide to understanding and utilizing the `test.sh` script for testing OpenIM RPC services. The `test.sh` script is a collection of bash functions designed to test various aspects of the OpenIM RPC services, ensuring that each part of the API is functioning as expected. -+ Scripts:https://github.com/OpenIMSDK/Open-IM-Server/tree/main/scripts/install/test.sh ++ Scripts:https://github.com/openimsdk/open-im-server/tree/main/scripts/install/test.sh -For some complex, bulky functional tests, performance tests, and various e2e tests, We are all in the current warehouse to https://github.com/OpenIMSDK/Open-IM-Server/tree/main/test or https://github.com/openim-sigs/test-infra directory In the. +For some complex, bulky functional tests, performance tests, and various e2e tests, We are all in the current warehouse to https://github.com/openimsdk/open-im-server/tree/main/test or https://github.com/openim-sigs/test-infra directory In the. + About OpenIM Feature [Test Docs](https://docs.google.com/spreadsheets/d/1zELWkwxgOOZ7u5pmYCqqaFnvZy2SVajv/edit?usp=sharing&ouid=103266350914914783293&rtpof=true&sd=true) +## Util Test -## Usage +Let's restructure and enhance the document under a unified second-level heading, adding clarity and details for better comprehension and visual appeal. + +--- + +## Development Guide + +### Comprehensive Testing Instructions + +#### Running Unit Tests + +- **Command**: To execute unit tests, input the following in your terminal: + ``` + make test + ``` + +#### Evaluating Test Coverage + +- **Overview**: It's crucial to assess how much of your code is covered by tests. +- **Command**: + ```bash + make cover + ``` + This command generates a report detailing the percentage of your code tested, ensuring adherence to quality standards. + +#### Conducting API Tests + +- **Purpose**: API tests validate the interaction and functionality of your application's interfaces. +- **How to Run**: + ``` + make test-api + ``` + Use this to check the integrity and reliability of your API endpoints. + +#### End-to-End (E2E) Testing + +- **Scope**: E2E tests simulate real-user scenarios from start to finish. +- **Execution**: + ``` + make test-e2e + ``` + This comprehensive testing ensures your application performs as expected in real-world situations. + +### Crafting Unit Test Cases + +#### Setup for Test Case Generation + +- **Installation**: Install the `gotests` tool to generate test cases automatically. + ```bash + make install.gotests + ``` + This command installs the `gotests` tool for test case generation. + +- **Environment Preparation**: Define your test template environment variable and generate test cases as shown below: + ```bash + export GOTESTS_TEMPLATE=testify + gotests -i -w -only keyFunc . + ``` + This prepares your environment for test case generation using the `testify` template. + +#### Isolating Function Tests + +- **Single Function Testing**: When you need to focus on testing a single function for detailed examination. +- **Method**: + ```bash + go test -v -run TestKeyFunc + ``` + This command specifically runs tests for `TestKeyFunc`, allowing targeted debugging and validation. + +### Important Note + +- **Quality Assurance**: Throughout your development process, it is imperative to ensure that the unit test coverage meets or surpasses the standards set by OpenIM. +- **Maintaining Standards**: Regularly running your tests with + ```make test``` + supports maintaining high code quality and adherence to OpenIM's rigorous testing benchmarks. + +## E2E Test + +TODO + +## Api Test The `test.sh` script is located within the `./scripts/install/` directory of the OpenIM service's codebase. To use the script, navigate to this directory from your terminal: diff --git a/docs/images/Open-IM.png b/docs/images/Open-IM.png deleted file mode 100644 index b617065505626ea5df9467ca5e945f851258aee6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17614 zcmZU*2RNJU8#Z3r(we3AtWs)Io1nF+)vAas6t!zhtkRa+_1d+HqLmpsu(y6z`JUss)+go)(FjT_{e8Y(Yu+#rPG|Nd}? z2>)rA3sJ)VBJg~vu5_bhfMo;!<(B<3oo6?0l*N(az_;<=@4nSA_PlX}qV3NQL8sgI z*Eepc*l4Oed*x@b6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=hR`Z*&j9p z{aGcp=56pP#7bDpIRRB+s;_`sxTBcm!oa6;K#u1)mS4PQby85}Sb4q9e07i?OPXGV_ diff --git a/docs/images/Architecture.jpg b/docs/images/architecture.jpg similarity index 100% rename from docs/images/Architecture.jpg rename to docs/images/architecture.jpg diff --git a/docs/images/Wechat.jpg b/docs/images/wechat.jpg similarity index 100% rename from docs/images/Wechat.jpg rename to docs/images/wechat.jpg diff --git a/pkg/common/discoveryregister/direct/directResolver.go b/pkg/common/discoveryregister/direct/direct_resolver.go similarity index 100% rename from pkg/common/discoveryregister/direct/directResolver.go rename to pkg/common/discoveryregister/direct/direct_resolver.go diff --git a/scripts/make-rules/common-versions.mk b/scripts/make-rules/common-versions.mk new file mode 100644 index 000000000..572585fce --- /dev/null +++ b/scripts/make-rules/common-versions.mk @@ -0,0 +1,58 @@ +# Copyright © 2023 OpenIMSDK. +# +# 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. +# ============================================================================== +# OpenIM Makefile Versions used +# +# Define the latest version for each tool to ensure consistent versioning across installations +GOLANGCI_LINT_VERSION ?= latest +GOIMPORTS_VERSION ?= latest +ADDLICENSE_VERSION ?= latest +DEEPCOPY_GEN_VERSION ?= latest +CONVERSION_GEN_VERSION ?= latest +GINKGO_VERSION ?= v1.16.2 +GO_GITLINT_VERSION ?= latest +GO_JUNIT_REPORT_VERSION ?= latest +GOTESTS_VERSION ?= latest +SWAGGER_VERSION ?= latest +KUBE_SCORE_VERSION ?= latest +KUBECONFORM_VERSION ?= latest +GSEMVER_VERSION ?= latest +GIT_CHGLOG_VERSION ?= latest +KO_VERSION ?= latest +GITHUB_RELEASE_VERSION ?= latest +COSCLI_VERSION ?= v0.19.0-beta +MINIO_VERSION ?= latest +DELVE_VERSION ?= latest +AIR_VERSION ?= latest +GOLINES_VERSION ?= latest +GO_MOD_OUTDATED_VERSION ?= latest +CFSSL_VERSION ?= latest +DEPTH_VERSION ?= latest +GO_CALLVIS_VERSION ?= latest +MISSPELL_VERSION ?= latest +GOTHANKS_VERSION ?= latest +RICHGO_VERSION ?= latest +RTS_VERSION ?= latest +TYPECHECK_VERSION ?= latest +COMMENT_LANG_DETECTOR_VERSION ?= latest +STANDARDIZER_VERSION ?= latest +GO_TESTS_VERSION ?= v1.6.0 +GO_APIDIFF_VERSION ?= v0.8.2 +KAFKACTL_VERSION ?= latest +GOTESTSUM_VERSION ?= latest + +WIRE_VERSION ?= latest +# WIRE_VERSION ?= $(call get_go_version,github.com/google/wire) +MOCKGEN_VERSION ?= $(call get_go_version,github.com/golang/mock) +PROTOC_GEN_GO_VERSION ?= $(call get_go_version,github.com/golang/protobuf/protoc-gen-go) \ No newline at end of file diff --git a/scripts/make-rules/common.mk b/scripts/make-rules/common.mk index f8537b6ca..ffbb69a55 100644 --- a/scripts/make-rules/common.mk +++ b/scripts/make-rules/common.mk @@ -78,6 +78,13 @@ VERSION := $(shell git describe --tags --always --match='v*') # v2.3.3: git tag endif +# Helper function to get dependency version from go.mod +get_gomod_version = $(shell go list -m $1 | awk '{print $$2}') +define go_install +$(info ===========> Installing $(1)@$(2)) +$(GO) install $(1)@$(2) +endef + # Check if the tree is dirty. default to dirty(maybe u should commit?) GIT_TREE_STATE:="dirty" ifeq (, $(shell git status --porcelain 2>/dev/null)) diff --git a/scripts/make-rules/tools.mk b/scripts/make-rules/tools.mk index 917c18cfe..5335d094d 100644 --- a/scripts/make-rules/tools.mk +++ b/scripts/make-rules/tools.mk @@ -64,81 +64,101 @@ tools.verify.%: ## install.golangci-lint: Install golangci-lint .PHONY: install.golangci-lint install.golangci-lint: - @$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + @$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) ## install.goimports: Install goimports, used to format go source files .PHONY: install.goimports install.goimports: - @$(GO) install golang.org/x/tools/cmd/goimports@latest + @$(GO) install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION) ## install.addlicense: Install addlicense, used to add license header to source files .PHONY: install.addlicense install.addlicense: - @$(GO) install github.com/google/addlicense@latest + @$(GO) install github.com/google/addlicense@$(ADDLICENSE_VERSION) ## install.deepcopy-gen: Install deepcopy-gen, used to generate deep copy functions .PHONY: install.deepcopy-gen install.deepcopy-gen: - @$(GO) install k8s.io/code-generator/cmd/deepcopy-gen@latest + @$(GO) install k8s.io/code-generator/cmd/deepcopy-gen@$(DEEPCOPY_GEN_VERSION) ## install.conversion-gen: Install conversion-gen, used to generate conversion functions .PHONY: install.conversion-gen install.conversion-gen: - @$(GO) install k8s.io/code-generator/cmd/conversion-gen@latest + @$(GO) install k8s.io/code-generator/cmd/conversion-gen@$(CONVERSION_GEN_VERSION) ## install.ginkgo: Install ginkgo to run a single test or set of tests .PHONY: install.ginkgo install.ginkgo: - @$(GO) install github.com/onsi/ginkgo/ginkgo@v1.16.2 + @$(GO) install github.com/onsi/ginkgo/ginkgo@$(GINKGO_VERSION) -## Install go-gitlint: Install go-gitlint, used to check git commit message +## install.go-gitlint: Install go-gitlint, used to check git commit message .PHONY: install.go-gitlint install.go-gitlint: - @$(GO) install github.com/marmotedu/go-gitlint/cmd/go-gitlint@latest + @$(GO) install github.com/marmotedu/go-gitlint/cmd/go-gitlint@$(GO_GITLINT_VERSION) ## install.go-junit-report: Install go-junit-report, used to convert go test output to junit xml .PHONY: install.go-junit-report install.go-junit-report: - @$(GO) install github.com/jstemmer/go-junit-report@latest + @$(GO) install github.com/jstemmer/go-junit-report@$(GO_JUNIT_REPORT_VERSION) ## install.gotests: Install gotests, used to generate go tests +.PHONY: install.gotests +install.gotests: + @$(GO) install github.com/cweill/gotests/gotests@$(GO_TESTS_VERSION) + +## install.kafkactl: Install kafkactl command line tool. +.PHONY: install.kafkactl +install.kafkactl: + @$(GO) install github.com/deviceinsight/kafkactl@$(KAFKACTL_VERSION) + +## install.go-apidiff: Install go-apidiff, used to check api changes +.PHONY: install.go-apidiff +install.go-apidiff: + @$(GO) install github.com/joelanford/go-apidiff@$(GO_APIDIFF_VERSION) + +## install.swagger: Install swagger, used to generate swagger documentation .PHONY: install.swagger install.swagger: - @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@latest + @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@$(SWAGGER_VERSION) # ============================================================================== # Tools that might be used include go gvm # +## install.gotestsum: Install gotestsum, used to run go tests +.PHONY: install.gotestsum +install.gotestsum: + @$(GO) install gotest.tools/gotestsum@$(GOTESTSUM_VERSION) + ## install.kube-score: Install kube-score, used to check kubernetes yaml files .PHONY: install.kube-score install.kube-score: - @$(GO) install github.com/zegl/kube-score/cmd/kube-score@latest + @$(GO) install github.com/zegl/kube-score/cmd/kube-score@$(KUBE_SCORE_VERSION) ## install.kubeconform: Install kubeconform, used to check kubernetes yaml files .PHONY: install.kubeconform install.kubeconform: - @$(GO) install github.com/yannh/kubeconform/cmd/kubeconform@latest + @$(GO) install github.com/yannh/kubeconform/cmd/kubeconform@$(KUBECONFORM_VERSION) ## install.gsemver: Install gsemver, used to generate semver .PHONY: install.gsemver install.gsemver: - @$(GO) install github.com/arnaud-deprez/gsemver@latest + @$(GO) install github.com/arnaud-deprez/gsemver@$(GSEMVER_VERSION) ## install.git-chglog: Install git-chglog, used to generate changelog .PHONY: install.git-chglog install.git-chglog: - @$(GO) install github.com/git-chglog/git-chglog/cmd/git-chglog@latest + @$(GO) install github.com/git-chglog/git-chglog/cmd/git-chglog@$(GIT_CHGLOG_VERSION) ## install.ko: Install ko, used to build go program into container images .PHONY: install.ko install.ko: - @$(GO) install github.com/google/ko@latest + @$(GO) install github.com/google/ko@$(KO_VERSION) ## install.github-release: Install github-release, used to create github release .PHONY: install.github-release install.github-release: - @$(GO) install github.com/github-release/github-release@latest + @$(GO) install github.com/github-release/github-release@$(GITHUB_RELEASE_VERSION) ## install.coscli: Install coscli, used to upload files to cos # example: ./coscli cp/sync -r /home/off-line/docker-off-line/ cos://openim-1306374445/openim/image/amd/off-line/off-line/ -e cos.ap-guangzhou.myqcloud.com @@ -146,7 +166,7 @@ install.github-release: # amd64 .PHONY: install.coscli install.coscli: - @wget -q https://github.com/tencentyun/coscli/releases/download/v0.19.0-beta/coscli-linux -O ${TOOLS_DIR}/coscli + @wget -q https://github.com/tencentyun/coscli/releases/download/$(COSCLI_VERSION)/coscli-linux -O ${TOOLS_DIR}/coscli @chmod +x ${TOOLS_DIR}/coscli ## install.coscmd: Install coscmd, used to upload files to cos @@ -157,50 +177,50 @@ install.coscmd: ## install.minio: Install minio, used to upload files to minio .PHONY: install.minio install.minio: - @$(GO) install github.com/minio/minio@latest + @$(GO) install github.com/minio/minio@$(MINIO_VERSION) ## install.delve: Install delve, used to debug go program .PHONY: install.delve install.delve: - @$(GO) install github.com/go-delve/delve/cmd/dlv@latest + @$(GO) install github.com/go-delve/delve/cmd/dlv@$(DELVE_VERSION) ## install.air: Install air, used to hot reload go program .PHONY: install.air install.air: - @$(GO) install github.com/cosmtrek/air@latest + @$(GO) install github.com/cosmtrek/air@$(AIR_VERSION) ## install.gvm: Install gvm, gvm is a Go version manager, built on top of the official go tool. -# github: https://github.com/moovweb/gvm .PHONY: install.gvm install.gvm: - @echo "===========> Installing gvm,The default installation path is ~/.gvm/scripts/gvm" + @echo "===========> Installing gvm, The default installation path is ~/.gvm/scripts/gvm" @bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) - @$(shell source /root/.gvm/scripts/gvm) + @source /root/.gvm/scripts/gvm ## install.golines: Install golines, used to format long lines .PHONY: install.golines install.golines: - @$(GO) install github.com/segmentio/golines@latest + @$(GO) install github.com/segmentio/golines@$(GOLINES_VERSION) ## install.go-mod-outdated: Install go-mod-outdated, used to check outdated dependencies .PHONY: install.go-mod-outdated install.go-mod-outdated: - @$(GO) install github.com/psampaz/go-mod-outdated@latest + @$(GO) install github.com/psampaz/go-mod-outdated@$(GO_MOD_OUTDATED_VERSION) ## install.mockgen: Install mockgen, used to generate mock functions .PHONY: install.mockgen install.mockgen: - @$(GO) install github.com/golang/mock/mockgen@latest + @$(GO) install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION) + +## install.wire: Install wire, used to generate wire files +.PHONY: install.wire +install.wire: + @$(GO) install github.com/google/wire/cmd/wire@$(WIRE_VERSION) -## install.gotests: Install gotests, used to generate test functions -.PHONY: install.gotests -install.gotests: - @$(GO) install github.com/cweill/gotests/gotests@latest ## install.protoc-gen-go: Install protoc-gen-go, used to generate go source files from protobuf files .PHONY: install.protoc-gen-go install.protoc-gen-go: - @$(GO) install github.com/golang/protobuf/protoc-gen-go@latest + @$(GO) install github.com/golang/protobuf/protoc-gen-go@$(PROTOC_GEN_GO_VERSION) ## install.cfssl: Install cfssl, used to generate certificates .PHONY: install.cfssl @@ -210,43 +230,49 @@ install.cfssl: ## install.depth: Install depth, used to check dependency tree .PHONY: install.depth install.depth: - @$(GO) install github.com/KyleBanks/depth/cmd/depth@latest + @$(GO) install github.com/KyleBanks/depth/cmd/depth@$(DEPTH_VERSION) ## install.go-callvis: Install go-callvis, used to visualize call graph .PHONY: install.go-callvis install.go-callvis: - @$(GO) install github.com/ofabry/go-callvis@latest + @$(GO) install github.com/ofabry/go-callvis@$(GO_CALLVIS_VERSION) -## install.misspell +## install.misspell: Install misspell .PHONY: install.misspell install.misspell: - @$(GO) install github.com/client9/misspell/cmd/misspell@latest + @$(GO) install github.com/client9/misspell/cmd/misspell@$(MISSPELL_VERSION) ## install.gothanks: Install gothanks, used to thank go dependencies .PHONY: install.gothanks install.gothanks: - @$(GO) install github.com/psampaz/gothanks@latest + @$(GO) install github.com/psampaz/gothanks@$(GOTHANKS_VERSION) ## install.richgo: Install richgo .PHONY: install.richgo install.richgo: - @$(GO) install github.com/kyoh86/richgo@latest + @$(GO) install github.com/kyoh86/richgo@$(RICHGO_VERSION) ## install.rts: Install rts .PHONY: install.rts install.rts: - @$(GO) install github.com/galeone/rts/cmd/rts@latest + @$(GO) install github.com/galeone/rts/cmd/rts@$(RTS_VERSION) # ================= kubecub openim tools ========================================= -## install.typecheck: install kubecub typecheck check for go code +# https://github.com/kubecub +## install.typecheck: Install kubecub typecheck, checks for go code .PHONY: install.typecheck install.typecheck: - @$(GO) install github.com/kubecub/typecheck@latest + @$(GO) install github.com/kubecub/typecheck@$(TYPECHECK_VERSION) -## install.comment-lang-detector: install kubecub comment-lang-detector check for go code comment language +## install.comment-lang-detector: Install kubecub comment-lang-detector, checks for go code comment language .PHONY: install.comment-lang-detector install.comment-lang-detector: - @$(GO) install github.com/kubecub/comment-lang-detector/cmd/cld@latest + @$(GO) install github.com/kubecub/comment-lang-detector/cmd/cld@$(COMMENT_LANG_DETECTOR_VERSION) + +## install.standardizer: Install kubecub standardizer, checks for go code standardization +.PHONY: install.standardizer +install.standardizer: + @$(GO) install github.com/kubecub/standardizer@$(STANDARDIZER_VERSION) ## tools.help: Display help information about the tools package .PHONY: tools.help diff --git a/scripts/verify-standardizer.sh b/scripts/verify-standardizer.sh new file mode 100755 index 000000000..08a13b9a2 --- /dev/null +++ b/scripts/verify-standardizer.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Copyright © 2023 OpenIM. 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. + +# This script does a fast type check of script srnetes code for all platforms. +# Usage: `scripts/verify-standardizer.sh`. + +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +source "${OPENIM_ROOT}/scripts/lib/init.sh" + +openim::golang::verify_go_version + +cd "${OPENIM_ROOT}" +ret=0 +scripts/run-in-gopath.sh \ +make tools.verify.standardizer +${OPENIM_ROOT}/_output/tools/standardizer || ret=$? +if [[ $ret -ne 0 ]]; then + openim::log::error "Failed to check the directory name or file name. Your name may not meet the specification. Please check the configuration file and the directory or file name." >&2 + openim::log::error "Please see https://github.com/kubecub/standardizer for more information." >&2 + exit 1 +fi diff --git a/test/testdata/requests/sendMessage.json b/test/testdata/requests/send-message.json similarity index 100% rename from test/testdata/requests/sendMessage.json rename to test/testdata/requests/send-message.json From db41c12d1f51784fe69a5ca29c2d33ed2f797358 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:05:00 +0800 Subject: [PATCH 33/86] Script Refactoring --- scripts-new/check.sh | 2 +- scripts-new/start.sh | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/scripts-new/check.sh b/scripts-new/check.sh index eb6028aa2..a0b066e5a 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -34,7 +34,7 @@ ret_val=$? if [ $ret_val -eq 0 ]; then echo "All services are running normally." else - echo "Some services are not running as expected." + echo "Some services are not running as expected. Details are as follows:" echo "$result" exit 1 fi diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 7a2d27404..aa4079b93 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -29,18 +29,5 @@ fi result=$(start_binaries) -result=$(check_binaries_running) -ret_val=$? -if [ $ret_val -eq 0 ]; then - echo "All binaries are running." -else - echo "$result" - echo "abort..." - exit 1 -fi - - -print_listened_ports_by_binaries - - +$OPENIM_SCRIPTS/check.sh From 5749268fd623b5a85cbad0fd06565587d2a258ea Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:09:31 +0800 Subject: [PATCH 34/86] Script Refactoring --- scripts-new/bricks.sh | 2 +- scripts-new/check.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 2feae3d89..8c325bd5b 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -3,7 +3,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/ source "${OPENIM_ROOT}/lib/util.sh" source "${OPENIM_ROOT}/define/binaries.sh" source "${OPENIM_ROOT}/lib/path.sh" - +source "${OPENIM_ROOT}/lib/logging.sh" #停止所有的二进制对应的进程 diff --git a/scripts-new/check.sh b/scripts-new/check.sh index a0b066e5a..128c5fe83 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -34,8 +34,8 @@ ret_val=$? if [ $ret_val -eq 0 ]; then echo "All services are running normally." else - echo "Some services are not running as expected. Details are as follows:" - echo "$result" + openim::log::error "Some services are not running as expected. Details are as follows:" + openim::log::error "$result" exit 1 fi From c75528f764da8b15b830e7980fdae1a1e8a26246 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:12:31 +0800 Subject: [PATCH 35/86] Script Refactoring --- scripts-new/bricks.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 8c325bd5b..fd51df6aa 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -1,5 +1,6 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/ +echo $OPENIM_ROOT 1111111111111111111111 source "${OPENIM_ROOT}/lib/util.sh" source "${OPENIM_ROOT}/define/binaries.sh" source "${OPENIM_ROOT}/lib/path.sh" From 6f142c7bc7d027e46a4564ca723360cda0d0e9a7 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:17:44 +0800 Subject: [PATCH 36/86] Script Refactoring --- scripts-new/bricks.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index fd51df6aa..5a01633d6 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -1,10 +1,8 @@ -OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/ -echo $OPENIM_ROOT 1111111111111111111111 -source "${OPENIM_ROOT}/lib/util.sh" -source "${OPENIM_ROOT}/define/binaries.sh" -source "${OPENIM_ROOT}/lib/path.sh" -source "${OPENIM_ROOT}/lib/logging.sh" +source "$(dirname "${BASH_SOURCE[0]}")/lib/util.sh" +source "$(dirname "${BASH_SOURCE[0]}")/define/binaries.sh" +source "$(dirname "${BASH_SOURCE[0]}")/lib/path.sh" +source "$(dirname "${BASH_SOURCE[0]}")/lib/logging.sh" #停止所有的二进制对应的进程 @@ -20,7 +18,7 @@ ERR_LOG_FILE=err.log.file #启动所有的二进制 start_binaries() { - local project_dir="$OPENIM_ROOT" # You should adjust this path as necessary + echo $ # Iterate over binaries defined in binary_path.sh for binary in "${!binaries[@]}"; do local count=${binaries[$binary]} From 022a0de1367e22b10566aa91bf6394eed0265a9f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:21:53 +0800 Subject: [PATCH 37/86] Script Refactoring --- scripts-new/bricks.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 5a01633d6..cf1e992b4 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -76,9 +76,7 @@ check_binaries_running(){ result=$(openim::util::check_process_names "$full_path" "$expected_count") ret_val=$? - if [ "$ret_val" -eq 0 ]; then - echo "$binary is running normally." - else + if [ "$ret_val" -ne 0 ]; then no_running_binaries=$((no_running_binaries + 1)) echo $result fi From 055b7de0ad110be866261abcd4ea01a8a48b3a19 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:25:33 +0800 Subject: [PATCH 38/86] Script Refactoring --- scripts-new/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/lib/util.sh b/scripts-new/lib/util.sh index b2edb758b..543d2c684 100644 --- a/scripts-new/lib/util.sh +++ b/scripts-new/lib/util.sh @@ -387,7 +387,7 @@ openim::util::check_process_names() { if [ "$running_count" -eq "$expected_count" ]; then return 0 else - echo "$process_path Expected $expected_count processes, but $running_count are present" + echo "$process_path Expected $expected_count processes, but $running_count running" return 1 fi } From 017c9fc55b520d2ec15046aa0a91164d875d2e63 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:28:01 +0800 Subject: [PATCH 39/86] Script Refactoring --- scripts-new/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index aa4079b93..a4f381069 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -20,14 +20,14 @@ ret_val=$? if [ $ret_val -ne 0 ]; then echo "$result" - echo "abort..." + echo "Some services running, abort start" exit 1 fi # Call the main function result=$(start_binaries) - +openim::log::status $result $OPENIM_SCRIPTS/check.sh From c95d3ddbc19147979c06a207fa5777c24d255cc0 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:28:41 +0800 Subject: [PATCH 40/86] Script Refactoring --- scripts-new/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index a4f381069..0e9dd3876 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -27,7 +27,7 @@ fi # Call the main function result=$(start_binaries) -openim::log::status $result +echo $result $OPENIM_SCRIPTS/check.sh From 6f0ee32d9ccd9daa48c763fbd23810019bc45c61 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:30:45 +0800 Subject: [PATCH 41/86] Script Refactoring --- scripts-new/bricks.sh | 2 +- scripts-new/start.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index cf1e992b4..4639128e4 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -25,7 +25,7 @@ start_binaries() { local bin_full_path=$(get_bin_full_path "$binary") # Loop to start binary the specified number of times for ((i=0; i> "${LOG_FILE}" 2> >(tee -a "$ERR_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & done diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 0e9dd3876..0ded7320c 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -27,7 +27,7 @@ fi # Call the main function result=$(start_binaries) -echo $result +openim::log::print_blue $result $OPENIM_SCRIPTS/check.sh From 4a597f65e7a3743cfe87c893bcd990e2c2a7b5fa Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:31:29 +0800 Subject: [PATCH 42/86] Script Refactoring --- scripts-new/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 0ded7320c..0e9dd3876 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -27,7 +27,7 @@ fi # Call the main function result=$(start_binaries) -openim::log::print_blue $result +echo $result $OPENIM_SCRIPTS/check.sh From dfb5fd0c553c1b80fd9d267d1d9561123338fed9 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:32:23 +0800 Subject: [PATCH 43/86] Script Refactoring --- scripts-new/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 0e9dd3876..792fbeca3 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -27,7 +27,7 @@ fi # Call the main function result=$(start_binaries) -echo $result +openim::log::success $result $OPENIM_SCRIPTS/check.sh From f2cd1665c129e519dffb0744775e118b7fa41838 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:32:57 +0800 Subject: [PATCH 44/86] Script Refactoring --- scripts-new/bricks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 4639128e4..9f730e3d9 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -25,7 +25,7 @@ start_binaries() { local bin_full_path=$(get_bin_full_path "$binary") # Loop to start binary the specified number of times for ((i=0; i> "${LOG_FILE}" 2> >(tee -a "$ERR_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & done From 3bc27905fdcd9354d1b266b9d60fafcfeea3b0a5 Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:33:05 +0800 Subject: [PATCH 45/86] refactor: remove info log. --- internal/api/msg.go | 1 - internal/msggateway/hub_server.go | 2 +- .../msgtransfer/online_history_msg_handler.go | 10 ++------ internal/push/offlinepush/getui/push.go | 2 +- internal/push/push_to_client.go | 2 +- internal/rpc/group/group.go | 2 +- internal/rpc/msg/revoke.go | 3 +-- pkg/common/db/cache/group.go | 2 +- pkg/common/db/controller/msg.go | 24 ++++--------------- pkg/common/db/mgo/msg.go | 4 ++-- .../kubernetes/kubernetes.go | 2 +- 11 files changed, 16 insertions(+), 38 deletions(-) diff --git a/internal/api/msg.go b/internal/api/msg.go index 92060fd12..42d5d8775 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -304,7 +304,6 @@ func (m *MessageApi) BatchSendMsg(c *gin.Context) { apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap()) return } - log.ZInfo(c, "BatchSendMsg", "req", req) if err := authverify.CheckAdmin(c, m.manager, m.imAdmin); err != nil { apiresp.GinError(c, errs.ErrNoPermission.WrapMsg("only app manager can send message")) return diff --git a/internal/msggateway/hub_server.go b/internal/msggateway/hub_server.go index 59a323152..a502e455a 100644 --- a/internal/msggateway/hub_server.go +++ b/internal/msggateway/hub_server.go @@ -187,7 +187,7 @@ func (s *Server) KickUserOffline( for _, v := range req.KickUserIDList { clients, _, ok := s.LongConnServer.GetUserPlatformCons(v, int(req.PlatformID)) if !ok { - log.ZInfo(ctx, "conn not exist", "userID", v, "platformID", req.PlatformID) + log.ZDebug(ctx, "conn not exist", "userID", v, "platformID", req.PlatformID) continue } diff --git a/internal/msgtransfer/online_history_msg_handler.go b/internal/msgtransfer/online_history_msg_handler.go index 0c4d55415..d532f6a71 100644 --- a/internal/msgtransfer/online_history_msg_handler.go +++ b/internal/msgtransfer/online_history_msg_handler.go @@ -315,14 +315,8 @@ func (och *OnlineHistoryRedisConsumerHandler) MessagesDistributionHandle() { for i, header := range consumerMessages[i].Headers { arr = append(arr, strconv.Itoa(i), string(header.Key), string(header.Value)) } - log.ZInfo( - ctx, - "consumer.kafka.GetContextWithMQHeader", - "len", - len(consumerMessages[i].Headers), - "header", - strings.Join(arr, ", "), - ) + log.ZInfo(ctx, "consumer.kafka.GetContextWithMQHeader", "len", len(consumerMessages[i].Headers), + "header", strings.Join(arr, ", ")) ctxMsg.ctx = kafka.GetContextWithMQHeader(consumerMessages[i].Headers) ctxMsg.message = msgFromMQ log.ZDebug( diff --git a/internal/push/offlinepush/getui/push.go b/internal/push/offlinepush/getui/push.go index 644a6c449..c3bd7e5d8 100644 --- a/internal/push/offlinepush/getui/push.go +++ b/internal/push/offlinepush/getui/push.go @@ -71,7 +71,7 @@ func (g *Client) Push(ctx context.Context, userIDs []string, title, content stri token, err := g.cache.GetGetuiToken(ctx) if err != nil { if errs.Unwrap(err) == redis.Nil { - log.ZInfo(ctx, "getui token not exist in redis") + log.ZDebug(ctx, "getui token not exist in redis") token, err = g.getTokenAndSave2Redis(ctx) if err != nil { return err diff --git a/internal/push/push_to_client.go b/internal/push/push_to_client.go index cf69fb13d..391c20559 100644 --- a/internal/push/push_to_client.go +++ b/internal/push/push_to_client.go @@ -237,7 +237,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws if p.UnmarshalNotificationElem(msg.Content, &tips) != nil { return err } - log.ZInfo(ctx, "GroupDismissedNotificationInfo****", "groupID", groupID, "num", len(pushToUserIDs), "list", pushToUserIDs) + log.ZDebug(ctx, "GroupDismissedNotificationInfo****", "groupID", groupID, "num", len(pushToUserIDs), "list", pushToUserIDs) if len(p.config.Manager.UserID) > 0 { ctx = mcontext.WithOpUserIDContext(ctx, p.config.Manager.UserID[0]) } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 143526ffa..880b3b38d 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -883,7 +883,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq) } else if !s.IsNotFound(err) && errs.Unwrap(err) != errs.ErrRecordNotFound { return nil, err } - log.ZInfo(ctx, "JoinGroup.groupInfo", "group", group, "eq", group.NeedVerification == constant.Directly) + log.ZDebug(ctx, "JoinGroup.groupInfo", "group", group, "eq", group.NeedVerification == constant.Directly) if group.NeedVerification == constant.Directly { groupMember := &relationtb.GroupMemberModel{ GroupID: group.GroupID, diff --git a/internal/rpc/msg/revoke.go b/internal/rpc/msg/revoke.go index d190ddcb3..59f3b84c3 100644 --- a/internal/rpc/msg/revoke.go +++ b/internal/rpc/msg/revoke.go @@ -32,7 +32,6 @@ import ( ) func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.RevokeMsgResp, error) { - defer log.ZDebug(ctx, "RevokeMsg return line") if req.UserID == "" { return nil, errs.ErrArgs.WrapMsg("user_id is empty") } @@ -61,7 +60,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg. } data, _ := json.Marshal(msgs[0]) - log.ZInfo(ctx, "GetMsgBySeqs", "conversationID", req.ConversationID, "seq", req.Seq, "msg", string(data)) + log.ZDebug(ctx, "GetMsgBySeqs", "conversationID", req.ConversationID, "seq", req.Seq, "msg", string(data)) var role int32 if !authverify.IsAppManagerUid(ctx, &m.config.Manager, &m.config.IMAdmin) { switch msgs[0].SessionType { diff --git a/pkg/common/db/cache/group.go b/pkg/common/db/cache/group.go index ed303e135..8b939e7d7 100644 --- a/pkg/common/db/cache/group.go +++ b/pkg/common/db/cache/group.go @@ -244,7 +244,7 @@ func (g *GroupCacheRedis) GetGroupMemberHashMap(ctx context.Context, groupIDs [] if err != nil { return nil, err } - log.ZInfo(ctx, "GetGroupMemberHashMap", "groupID", groupID, "hash", hash) + log.ZDebug(ctx, "GetGroupMemberHashMap", "groupID", groupID, "hash", hash) num, err := g.GetGroupMemberNum(ctx, groupID) if err != nil { return nil, err diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index 7a6a2fc02..e680cd491 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -533,7 +533,7 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin } // "minSeq" represents the startSeq value that the user can retrieve. if minSeq > end { - log.ZInfo(ctx, "minSeq > end", "minSeq", minSeq, "end", end) + log.ZWarn(ctx, "minSeq > end", errs.New("minSeq>end"), "minSeq", minSeq, "end", end) return 0, 0, nil, nil } maxSeq, err := db.cache.GetMaxSeq(ctx, conversationID) @@ -681,22 +681,8 @@ func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, co log.ZError(ctx, "get message from redis exception", err, "failedSeqs", failedSeqs, "conversationID", conversationID) } } - log.ZInfo( - ctx, - "db.cache.GetMessagesBySeq", - "userID", - userID, - "conversationID", - conversationID, - "seqs", - seqs, - "successMsgs", - len(successMsgs), - "failedSeqs", - failedSeqs, - "conversationID", - conversationID, - ) + log.ZDebug(ctx, "db.cache.GetMessagesBySeq", "userID", userID, "conversationID", conversationID, "seqs", + seqs, "len(successMsgs)", len(successMsgs), "failedSeqs", failedSeqs) if len(failedSeqs) > 0 { mongoMsgs, err := db.getMsgBySeqs(ctx, userID, conversationID, failedSeqs) @@ -717,7 +703,7 @@ func (db *commonMsgDatabase) DeleteConversationMsgsAndSetMinSeq(ctx context.Cont if err != nil { return err } - log.ZInfo(ctx, "DeleteConversationMsgsAndSetMinSeq", "conversationID", conversationID, "minSeq", minSeq) + log.ZDebug(ctx, "DeleteConversationMsgsAndSetMinSeq", "conversationID", conversationID, "minSeq", minSeq) if minSeq == 0 { return nil } @@ -896,7 +882,7 @@ func (db *commonMsgDatabase) CleanUpUserConversationsMsgs(ctx context.Context, u maxSeq, err := db.cache.GetMaxSeq(ctx, conversationID) if err != nil { if err == redis.Nil { - log.ZInfo(ctx, "max seq is nil", "conversationID", conversationID) + log.ZDebug(ctx, "max seq is nil", "conversationID", conversationID) } else { log.ZError(ctx, "get max seq failed", err, "conversationID", conversationID) } diff --git a/pkg/common/db/mgo/msg.go b/pkg/common/db/mgo/msg.go index 697d3a065..40ee5e423 100644 --- a/pkg/common/db/mgo/msg.go +++ b/pkg/common/db/mgo/msg.go @@ -859,7 +859,7 @@ func (m *MsgMgo) ConvertMsgsDocLen(ctx context.Context, conversationIDs []string if len(msgDocs) < 1 { continue } - log.ZInfo(ctx, "msg doc convert", "conversationID", conversationID, "len(msgDocs)", len(msgDocs)) + log.ZDebug(ctx, "msg doc convert", "conversationID", conversationID, "len(msgDocs)", len(msgDocs)) if len(msgDocs[0].Msg) == int(m.model.GetSingleGocMsgNum5000()) { if err := mongoutil.DeleteMany(ctx, m.coll, bson.M{"doc_id": regex}); err != nil { log.ZError(ctx, "convertAll delete many failed", err, "conversationID", conversationID) @@ -891,7 +891,7 @@ func (m *MsgMgo) ConvertMsgsDocLen(ctx context.Context, conversationIDs []string if err = mongoutil.InsertMany(ctx, m.coll, newMsgDocs); err != nil { log.ZError(ctx, "convertAll insert many failed", err, "conversationID", conversationID, "len(newMsgDocs)", len(newMsgDocs)) } else { - log.ZInfo(ctx, "msg doc convert", "conversationID", conversationID, "len(newMsgDocs)", len(newMsgDocs)) + log.ZDebug(ctx, "msg doc convert", "conversationID", conversationID, "len(newMsgDocs)", len(newMsgDocs)) } } } diff --git a/pkg/common/discoveryregister/kubernetes/kubernetes.go b/pkg/common/discoveryregister/kubernetes/kubernetes.go index 302393ed0..90fc314db 100644 --- a/pkg/common/discoveryregister/kubernetes/kubernetes.go +++ b/pkg/common/discoveryregister/kubernetes/kubernetes.go @@ -124,7 +124,7 @@ func getMsgGatewayHost(ctx context.Context, gatewayName string) []string { host := fmt.Sprintf("%s-openim-msggateway-%d.%s-openim-msggateway-headless.%s.svc.cluster.local:%d", instance, i, instance, ns, port) ret = append(ret, host) } - log.ZInfo(ctx, "getMsgGatewayHost", "instance", instance, "selfPodName", selfPodName, "replicas", replicas, "ns", ns, "ret", ret) + log.ZDebug(ctx, "getMsgGatewayHost", "instance", instance, "selfPodName", selfPodName, "replicas", replicas, "ns", ns, "ret", ret) return ret } From e84ec680b66d2638dee69c1b6955cf2f73c80538 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:35:04 +0800 Subject: [PATCH 46/86] Script Refactoring --- scripts-new/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 792fbeca3..756e2e0c0 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -27,7 +27,7 @@ fi # Call the main function result=$(start_binaries) -openim::log::success $result +openim::log::success "$result" $OPENIM_SCRIPTS/check.sh From f959decfedd1d8a93a2a8091c0144ca616b73a40 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:36:28 +0800 Subject: [PATCH 47/86] Script Refactoring --- scripts-new/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 756e2e0c0..cff1ccf09 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -27,7 +27,7 @@ fi # Call the main function result=$(start_binaries) -openim::log::success "$result" +echo "$result" $OPENIM_SCRIPTS/check.sh From 935996670e12a5411f97eca82ef07a1d5e07de12 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:39:04 +0800 Subject: [PATCH 48/86] Script Refactoring --- scripts-new/bricks.sh | 1 - scripts-new/start.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 9f730e3d9..b8f352d3f 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -18,7 +18,6 @@ ERR_LOG_FILE=err.log.file #启动所有的二进制 start_binaries() { - echo $ # Iterate over binaries defined in binary_path.sh for binary in "${!binaries[@]}"; do local count=${binaries[$binary]} diff --git a/scripts-new/start.sh b/scripts-new/start.sh index cff1ccf09..7f85e1ed7 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -27,7 +27,7 @@ fi # Call the main function result=$(start_binaries) -echo "$result" +openim::log::status "$result" $OPENIM_SCRIPTS/check.sh From a7658e638991fe870979d5659b50c6e4f7f0693b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:42:53 +0800 Subject: [PATCH 49/86] Script Refactoring --- scripts-new/lib/logging.sh | 3 ++- scripts-new/start.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index 0d15463eb..c0ee9cef1 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -255,7 +255,8 @@ function openim::log::test_log() { # openim::log::test_log function openim::log::print_blue() { - echo -e "\033[0;36m$1\033[0m" + local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") + echo -e "\033[0;36m[$current_time] $1\033[0m" } diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 7f85e1ed7..f8a24ad01 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -27,7 +27,7 @@ fi # Call the main function result=$(start_binaries) -openim::log::status "$result" +openim::log::print_blue "$result" $OPENIM_SCRIPTS/check.sh From 2fe30518e0c9db93c4863975e006d82d870fbd2f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:44:48 +0800 Subject: [PATCH 50/86] Script Refactoring --- scripts-new/lib/logging.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index c0ee9cef1..f6f7b7e34 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -256,10 +256,12 @@ function openim::log::test_log() { function openim::log::print_blue() { local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") - echo -e "\033[0;36m[$current_time] $1\033[0m" + echo -e "[$current_time]" + echo -e "\033[0;34m$1\033[0m" } + openim::log::colorless() { local V="${V:-0}" if [[ ${OPENIM_VERBOSE} < ${V} ]]; then From 0fcb5405dea722884d2457959a866a9b53b06225 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:46:30 +0800 Subject: [PATCH 51/86] Script Refactoring --- scripts-new/check.sh | 4 ++-- scripts-new/lib/logging.sh | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts-new/check.sh b/scripts-new/check.sh index 128c5fe83..f28efc405 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -34,8 +34,8 @@ ret_val=$? if [ $ret_val -eq 0 ]; then echo "All services are running normally." else - openim::log::error "Some services are not running as expected. Details are as follows:" - openim::log::error "$result" + openim::log::print_red "Some services are not running as expected. Details are as follows:" + openim::log::print_red "$result" exit 1 fi diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index f6f7b7e34..642ed1395 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -260,6 +260,13 @@ function openim::log::print_blue() { echo -e "\033[0;34m$1\033[0m" } +function openim::log::print_red() { + local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") + echo -e "[$current_time]" + echo -e "\033[0;31m$1\033[0m" +} + + openim::log::colorless() { From e2a9fb104b71c7bbee04da5613af7b9895061414 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:49:04 +0800 Subject: [PATCH 52/86] Script Refactoring --- scripts-new/lib/logging.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index 642ed1395..67864f706 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -262,8 +262,17 @@ function openim::log::print_blue() { function openim::log::print_red() { local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") - echo -e "[$current_time]" - echo -e "\033[0;31m$1\033[0m" + local msg_length=${#1} + local time_length=${#current_time} + local term_width=$(tput cols) + + local total_length=$((time_length + msg_length + 2)) + + if [ $total_length -gt $term_width ]; then + echo -e "[$current_time]\n\033[0;31m$1\033[0m" + else + echo -e "[$current_time] \033[0;31m$1\033[0m" + fi } From f3f2c6a94866580f6799678f12d6a4ad090e4c4b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:50:05 +0800 Subject: [PATCH 53/86] Script Refactoring --- scripts-new/lib/logging.sh | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index 67864f706..642ed1395 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -262,17 +262,8 @@ function openim::log::print_blue() { function openim::log::print_red() { local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") - local msg_length=${#1} - local time_length=${#current_time} - local term_width=$(tput cols) - - local total_length=$((time_length + msg_length + 2)) - - if [ $total_length -gt $term_width ]; then - echo -e "[$current_time]\n\033[0;31m$1\033[0m" - else - echo -e "[$current_time] \033[0;31m$1\033[0m" - fi + echo -e "[$current_time]" + echo -e "\033[0;31m$1\033[0m" } From 6639601155472b0456b1827df7f5c8d2da4327ac Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:54:02 +0800 Subject: [PATCH 54/86] Script Refactoring --- scripts-new/lib/logging.sh | 15 ++++++++++++--- scripts-new/start.sh | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index 642ed1395..19c78c768 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -254,21 +254,30 @@ function openim::log::test_log() { # openim::log::test_log -function openim::log::print_blue() { + +function openim::log::print_blue_two_line() { local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") echo -e "[$current_time]" echo -e "\033[0;34m$1\033[0m" } +function openim::log::print_blue() { + local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") + echo -e "[$current_time] \033[0;34m$1\033[0m" +} + + + + function openim::log::print_red() { local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") - echo -e "[$current_time]" - echo -e "\033[0;31m$1\033[0m" + echo -e "[$current_time] \033[0;31m$1\033[0m" } + openim::log::colorless() { local V="${V:-0}" if [[ ${OPENIM_VERBOSE} < ${V} ]]; then diff --git a/scripts-new/start.sh b/scripts-new/start.sh index f8a24ad01..8ba1be2bf 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -27,7 +27,7 @@ fi # Call the main function result=$(start_binaries) -openim::log::print_blue "$result" +openim::log::print_blue_two_line "$result" $OPENIM_SCRIPTS/check.sh From 296623b3d5cfa3b624ad0af99e89afda53ddf130 Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:57:09 +0800 Subject: [PATCH 55/86] refactor: config change. --- config/openim-api.yml | 2 +- config/openim-msggateway.yml | 14 ++------------ config/openim-msgtransfer.yml | 13 +------------ config/openim-push.yml | 14 ++------------ config/openim-rpc-auth.yml | 13 +------------ config/openim-rpc-conversation.yml | 14 ++------------ config/openim-rpc-friend.yml | 13 +------------ config/openim-rpc-group.yml | 14 ++------------ config/openim-rpc-msg.yml | 14 ++------------ config/openim-rpc-third.yml | 14 ++------------ config/openim-rpc-user.yml | 14 ++------------ 11 files changed, 18 insertions(+), 121 deletions(-) diff --git a/config/openim-api.yml b/config/openim-api.yml index 85a693b2f..bba68f95d 100644 --- a/config/openim-api.yml +++ b/config/openim-api.yml @@ -4,4 +4,4 @@ api: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] \ No newline at end of file + prometheusPort: [20100] \ No newline at end of file diff --git a/config/openim-msggateway.yml b/config/openim-msggateway.yml index 70a6a275e..370a96ffb 100644 --- a/config/openim-msggateway.yml +++ b/config/openim-msggateway.yml @@ -7,16 +7,6 @@ longConnSvr: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [ 20140 ] + diff --git a/config/openim-msgtransfer.yml b/config/openim-msgtransfer.yml index edfc0e414..3df57d713 100644 --- a/config/openim-msgtransfer.yml +++ b/config/openim-msgtransfer.yml @@ -2,15 +2,4 @@ prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports diff --git a/config/openim-push.yml b/config/openim-push.yml index 089df88be..69ab6eef4 100644 --- a/config/openim-push.yml +++ b/config/openim-push.yml @@ -17,15 +17,5 @@ push: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [ 20170 ] + diff --git a/config/openim-rpc-auth.yml b/config/openim-rpc-auth.yml index 6ba1e91d8..91e393fb0 100644 --- a/config/openim-rpc-auth.yml +++ b/config/openim-rpc-auth.yml @@ -8,15 +8,4 @@ rpcRegisterName: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [20160] \ No newline at end of file diff --git a/config/openim-rpc-conversation.yml b/config/openim-rpc-conversation.yml index 40e988bd0..7c5a9abd6 100644 --- a/config/openim-rpc-conversation.yml +++ b/config/openim-rpc-conversation.yml @@ -8,15 +8,5 @@ rpcRegisterName: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [ 20230 ] + diff --git a/config/openim-rpc-friend.yml b/config/openim-rpc-friend.yml index 12de99fee..abb3824ac 100644 --- a/config/openim-rpc-friend.yml +++ b/config/openim-rpc-friend.yml @@ -8,15 +8,4 @@ rpcRegisterName: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [ 20120 ] diff --git a/config/openim-rpc-group.yml b/config/openim-rpc-group.yml index 0e4325771..841b3242b 100644 --- a/config/openim-rpc-group.yml +++ b/config/openim-rpc-group.yml @@ -8,15 +8,5 @@ rpcRegisterName: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [ 20150 ] + diff --git a/config/openim-rpc-msg.yml b/config/openim-rpc-msg.yml index 91a3aa543..761e71162 100644 --- a/config/openim-rpc-msg.yml +++ b/config/openim-rpc-msg.yml @@ -8,15 +8,5 @@ rpcRegisterName: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [ 20130 ] + diff --git a/config/openim-rpc-third.yml b/config/openim-rpc-third.yml index d73fed587..f428eb1a2 100644 --- a/config/openim-rpc-third.yml +++ b/config/openim-rpc-third.yml @@ -9,15 +9,5 @@ rpcRegisterName: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [ 21301 ] + diff --git a/config/openim-rpc-user.yml b/config/openim-rpc-user.yml index 1934e759f..3e66088f9 100644 --- a/config/openim-rpc-user.yml +++ b/config/openim-rpc-user.yml @@ -9,15 +9,5 @@ rpcRegisterName: prometheus: enable: true grafanaUrl: http://127.0.0.1:13000/ - apiPrometheusPort: [20100] - userPrometheusPort: [ 20110 ] - friendPrometheusPort: [ 20120 ] - messagePrometheusPort: [ 20130 ] - messageGatewayPrometheusPort: [ 20140 ] - groupPrometheusPort: [ 20150 ] - authPrometheusPort: [ 20160 ] - pushPrometheusPort: [ 20170 ] - conversationPrometheusPort: [ 20230 ] - rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports + prometheusPort: [ 20110 ] + From fd237285e45dfd669d2b87a15eeefb7fa6535513 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:57:18 +0800 Subject: [PATCH 56/86] Script Refactoring --- scripts-new/check.sh | 3 ++- scripts-new/lib/logging.sh | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts-new/check.sh b/scripts-new/check.sh index f28efc405..fdaa26de8 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -40,6 +40,7 @@ else fi -print_listened_ports_by_binaries +result=$(print_listened_ports_by_binaries) +print_green_two_line "$result" diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index 19c78c768..51e2e20b1 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -267,6 +267,11 @@ function openim::log::print_blue() { } +function openim::log::print_green_two_line() { + local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") + echo -e "[$current_time]" + echo -e "\033[0;32m$1\033[0m" +} function openim::log::print_red() { From c9268170bc70ad545931e6599ca30032b20512d3 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 16:58:06 +0800 Subject: [PATCH 57/86] Script Refactoring --- scripts-new/check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/check.sh b/scripts-new/check.sh index fdaa26de8..383cd8c22 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -41,6 +41,6 @@ fi result=$(print_listened_ports_by_binaries) -print_green_two_line "$result" +openim::log::print_green_two_line "$result" From 4436d388b39e036ba46d4a1cf727a0b58d730d62 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:01:33 +0800 Subject: [PATCH 58/86] Script Refactoring --- scripts-new/check.sh | 2 +- scripts-new/lib/logging.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts-new/check.sh b/scripts-new/check.sh index 383cd8c22..5493fb914 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -32,7 +32,7 @@ source "$OPENIM_SCRIPTS/bricks.sh" result=$(check_binaries_running) ret_val=$? if [ $ret_val -eq 0 ]; then - echo "All services are running normally." + openim::log::print_green "All services are running normally." else openim::log::print_red "Some services are not running as expected. Details are as follows:" openim::log::print_red "$result" diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index 51e2e20b1..ffde53d85 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -273,6 +273,11 @@ function openim::log::print_green_two_line() { echo -e "\033[0;32m$1\033[0m" } +function openim::log::print_green() { + local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") + echo -e "[$current_time] \033[0;32m$1\033[0m" +} + function openim::log::print_red() { local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") From aa151878f9436295c6a4bdf3acc6babd60d94b1d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:04:08 +0800 Subject: [PATCH 59/86] Script Refactoring --- scripts-new/lib/util.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts-new/lib/util.sh b/scripts-new/lib/util.sh index 543d2c684..e725673d0 100644 --- a/scripts-new/lib/util.sh +++ b/scripts-new/lib/util.sh @@ -2455,8 +2455,6 @@ function openim::util::print_binary_ports() { # Check if the binary is running if pgrep -f "$binary_path" > /dev/null; then - # echo "$binary_name is running." "arg $1" - # Find the PID(s) of the running binary pids=$(pgrep -f "$binary_path") @@ -2468,11 +2466,9 @@ function openim::util::print_binary_ports() { # Check for listening ports using lsof if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux - # Append found ports to the ports variable, followed by a space ports+=$(lsof -i -n | grep LISTEN | grep "$pid" | awk '{print $9}' | cut -d':' -f2 | uniq | tr '\n' ' ') elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS - # Append found ports to the ports variable, followed by a space ports+=$(lsof -i -n | grep LISTEN | grep "$pid" | awk '{print $9}' | awk -F'[:\.]+' '{print $(NF-1)}' | uniq | tr '\n' ' ') fi done @@ -2492,6 +2488,7 @@ function openim::util::print_binary_ports() { + function openim::util::kill_exist_binary() { local binary_path="$1" local pids=$(pgrep -f "$binary_path") From 1a6e850671a45e00c1897832c9c3d32b3c1e9d97 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:07:21 +0800 Subject: [PATCH 60/86] Script Refactoring --- scripts-new/lib/util.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-new/lib/util.sh b/scripts-new/lib/util.sh index e725673d0..c0d28abca 100644 --- a/scripts-new/lib/util.sh +++ b/scripts-new/lib/util.sh @@ -2477,9 +2477,9 @@ function openim::util::print_binary_ports() { ports=$(echo "$ports" | xargs | tr ' ' '\n' | uniq | tr '\n' ' ') if [ -z "$ports" ]; then - echo "$binary_path is not listening on any ports." + echo "$binary_path is not listening on any ports." ["$ports"] else - echo "$binary_path is listening on the following ports: $ports" + echo "$binary_path is listening on the following ports: $ports" ["$ports"] fi else echo "$binary_path is not running." From 96777bbf2fc74a83bae4df054277826bbbc7de44 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:09:31 +0800 Subject: [PATCH 61/86] Script Refactoring --- scripts-new/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/lib/util.sh b/scripts-new/lib/util.sh index c0d28abca..9d2170a70 100644 --- a/scripts-new/lib/util.sh +++ b/scripts-new/lib/util.sh @@ -2476,7 +2476,7 @@ function openim::util::print_binary_ports() { # Remove trailing spaces and duplicate ports if any ports=$(echo "$ports" | xargs | tr ' ' '\n' | uniq | tr '\n' ' ') - if [ -z "$ports" ]; then + if [[ ! -n "$ports" ]]; then echo "$binary_path is not listening on any ports." ["$ports"] else echo "$binary_path is listening on the following ports: $ports" ["$ports"] From 38c1fe40fe08ba186e846efe2bb5829b9638b9b1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:12:25 +0800 Subject: [PATCH 62/86] Script Refactoring --- scripts-new/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/lib/util.sh b/scripts-new/lib/util.sh index 9d2170a70..48ca21875 100644 --- a/scripts-new/lib/util.sh +++ b/scripts-new/lib/util.sh @@ -2476,7 +2476,7 @@ function openim::util::print_binary_ports() { # Remove trailing spaces and duplicate ports if any ports=$(echo "$ports" | xargs | tr ' ' '\n' | uniq | tr '\n' ' ') - if [[ ! -n "$ports" ]]; then + if [[ ${#ports} -eq 1 ]]; then echo "$binary_path is not listening on any ports." ["$ports"] else echo "$binary_path is listening on the following ports: $ports" ["$ports"] From 1d245a1d266242eefbb50b0149a5c85489badc95 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:13:30 +0800 Subject: [PATCH 63/86] Script Refactoring --- scripts-new/lib/util.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-new/lib/util.sh b/scripts-new/lib/util.sh index 48ca21875..d6fb88358 100644 --- a/scripts-new/lib/util.sh +++ b/scripts-new/lib/util.sh @@ -2477,9 +2477,9 @@ function openim::util::print_binary_ports() { ports=$(echo "$ports" | xargs | tr ' ' '\n' | uniq | tr '\n' ' ') if [[ ${#ports} -eq 1 ]]; then - echo "$binary_path is not listening on any ports." ["$ports"] + echo "$binary_path is not listening on any ports." else - echo "$binary_path is listening on the following ports: $ports" ["$ports"] + echo "$binary_path is listening on the following ports: $ports" fi else echo "$binary_path is not running." From d417645d4892c4acb83c7349f91ce1e9337da2e5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:20:34 +0800 Subject: [PATCH 64/86] Script Refactoring --- scripts-new/bricks.sh | 2 -- scripts-new/lib/logging.sh | 5 +++++ scripts-new/stop.sh | 7 +++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index b8f352d3f..d6ea44f12 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -56,10 +56,8 @@ check_binaries_stop() { done if [ "$running_binaries" -ne 0 ]; then - echo "There are $running_binaries binaries still running. Aborting..." return 1 else - echo "All processes have been stopped." return 0 fi } diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index ffde53d85..b2cf8e307 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -284,6 +284,11 @@ function openim::log::print_red() { echo -e "[$current_time] \033[0;31m$1\033[0m" } +function openim::log::print_red_two_lines() { + local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") + echo -e "[$current_time]" + echo -e "\033[0;31m$1\033[0m" +} diff --git a/scripts-new/stop.sh b/scripts-new/stop.sh index 2ea534525..9772b3cd0 100644 --- a/scripts-new/stop.sh +++ b/scripts-new/stop.sh @@ -14,11 +14,10 @@ kill_exist_binaries result=$(check_binaries_stop) ret_val=$? - if [ $ret_val -ne 0 ]; then - echo "$result" - echo "no stop..." + openim::log::print_red "Some services have not been stopped, details are as follows:" + openim::log::print_red_two_lines "$result" exit 1 fi -echo "all stop" \ No newline at end of file +openim::log::print_green "All services have been stopped" \ No newline at end of file From 9a835f616fb64b55aa948a76e85d4987505db237 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:21:46 +0800 Subject: [PATCH 65/86] Script Refactoring --- scripts-new/check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/check.sh b/scripts-new/check.sh index 5493fb914..f245f339e 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -35,7 +35,7 @@ if [ $ret_val -eq 0 ]; then openim::log::print_green "All services are running normally." else openim::log::print_red "Some services are not running as expected. Details are as follows:" - openim::log::print_red "$result" + openim::log::print_red_two_lines "$result" exit 1 fi From 637716c729c118a8bd20accbda113c7b77c983d0 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:25:16 +0800 Subject: [PATCH 66/86] Script Refactoring --- scripts-new/bricks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index d6ea44f12..590610973 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -24,7 +24,7 @@ start_binaries() { local bin_full_path=$(get_bin_full_path "$binary") # Loop to start binary the specified number of times for ((i=0; i> "${LOG_FILE}" 2> >(tee -a "$ERR_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & done From 614250665b8a9269e67aab61a2e21d48ac040ae1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:26:09 +0800 Subject: [PATCH 67/86] Script Refactoring --- scripts-new/bricks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 590610973..52a42613e 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -24,7 +24,7 @@ start_binaries() { local bin_full_path=$(get_bin_full_path "$binary") # Loop to start binary the specified number of times for ((i=0; i> "${LOG_FILE}" 2> >(tee -a "$ERR_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & done From 390c5b3e8b1cef66c0d878d4af6c3e5537fc1f6f Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Tue, 2 Apr 2024 17:27:24 +0800 Subject: [PATCH 68/86] feat: add code lint --- .gitignore | 1 - .golangci.yml | 46 ++++++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 5142fe551..fb8d428d2 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,6 @@ deployments/charts/generated-configs/ ### OpenIM Config ### .env config/config.yaml -config/openim.yaml config/alertmanager.yml config/prometheus.yml config/email.tmpl diff --git a/.golangci.yml b/.golangci.yml index 6b8469b62..f0ca3a010 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -39,19 +39,19 @@ run: # from this option's value (see skip-dirs-use-default). # "/" will be replaced by current OS file path separator to properly work # on Windows. - skip-dirs: - - components - - docs - - util - - .*~ - - api/swagger/docs - - server/docs - - components/mnt/config/certs - - logs + # skip-dirs: + # - components + # - docs + # - util + # - .*~ + # - api/swagger/docs + # - server/docs + # - components/mnt/config/certs + # - logs # default is true. Enables skipping of directories: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs-use-default: true + # skip-dirs-use-default: true # which files to skip: they will be analyzed, but issues from them # won't be reported. Default value is empty list, but there is @@ -59,15 +59,15 @@ run: # autogenerated files. If it's not please let us know. # "/" will be replaced by current OS file path separator to properly work # on Windows. - skip-files: - - ".*\\.my\\.go$" - - _test.go - - ".*_test.go" - - "mocks/" - - ".github/" - - "logs/" - - "_output/" - - "components/" + # skip-files: + # - ".*\\.my\\.go$" + # - _test.go + # - ".*_test.go" + # - "mocks/" + # - ".github/" + # - "logs/" + # - "_output/" + # - "components/" # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit @@ -87,7 +87,7 @@ run: # output configuration options output: # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: colored-line-number + # format: colored-line-number # print lines of code with issue, default is true print-issued-lines: true @@ -150,6 +150,11 @@ linters-settings: comparison: true exhaustive: + # Program elements to check for exhaustiveness. + # Default: [ switch ] + check: + - switch + - map # check switch statements in generated files also check-generated: false # indicates that switch statements are to be considered exhaustive if a @@ -772,6 +777,7 @@ linters: - dupword - errname - gci + - exhaustive - gocritic - goprintffuncname - gomnd From cee74a016a74dab5e2842be75aaea0651a3f88a6 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Tue, 2 Apr 2024 17:28:13 +0800 Subject: [PATCH 69/86] feat: add code lint --- config/openim.yaml | 260 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 config/openim.yaml diff --git a/config/openim.yaml b/config/openim.yaml new file mode 100644 index 000000000..4f17d24af --- /dev/null +++ b/config/openim.yaml @@ -0,0 +1,260 @@ +# openim.yaml 作为存放一些通用配置或特殊配置的文件,我们将包含日志、消息缓存、多登录策略、消息验证策略等配置。 +# 这些配置是跨多个服务的共享配置,它们对于整个系统的运行至关重要。 +log: + storageLocation: /data/workspaces/open-im-server/_output/logs/ + rotationTime: 24 + remainRotationCount: 2 + remainLogLevel: 6 + isStdout: false + isJson: false + withStack: false + +msgCacheTimeout: 86400 + +multiLoginPolicy: 1 + +messageVerify: + friendVerify: false + +tokenPolicy: + expire: 90 + +groupMessageHasReadReceiptEnable: true + +singleMessageHasReadReceiptEnable: true + +retainChatRecords: 365 + +chatRecordsClearTime: "0 2 * * 3" + +msgDestructTime: "0 2 * * *" + +secret: openIM123 + +iosPush: + pushSound: "xxx" + badgeCount: true + production: false + + +###################### Third-party service configuration ###################### +# Callback configuration +# +# Callback URL +# Whether to enable this callback event +# Timeout in seconds +# Whether to continue execution if callback fails +callback: + url: "http://127.0.0.1:10008/callbackExample" + beforeSendSingleMsg: + enable: false + timeout: 5 + failedContinue: true + beforeUpdateUserInfoEx: + enable: false + timeout: 5 + failedContinue: true + afterUpdateUserInfoEx: + enable: false + timeout: 5 + failedContinue: true + afterSendSingleMsg: + enable: false + timeout: 5 + failedContinue: true + beforeSendGroupMsg: + enable: false + timeout: 5 + failedContinue: true + afterSendGroupMsg: + enable: false + timeout: 5 + failedContinue: true + msgModify: + enable: false + timeout: 5 + failedContinue: true + userOnline: + enable: false + timeout: 5 + failedContinue: true + userOffline: + enable: false + timeout: 5 + failedContinue: true + userKickOff: + enable: false + timeout: 5 + failedContinue: true + offlinePush: + enable: false + timeout: 5 + failedContinue: true + onlinePush: + enable: false + timeout: 5 + failedContinue: true + superGroupOnlinePush: + enable: false + timeout: 5 + failedContinue: true + beforeAddFriend: + enable: false + timeout: 5 + failedContinue: true + beforeUpdateUserInfo: + enable: false + timeout: 5 + failedContinue: true + beforeCreateGroup: + enable: false + timeout: 5 + failedContinue: true + afterCreateGroup: + enable: false + timeout: 5 + failedContinue: true + beforeMemberJoinGroup: + enable: false + timeout: 5 + failedContinue: true + beforeSetGroupMemberInfo: + enable: false + timeout: 5 + failedContinue: true + afterSetGroupMemberInfo: + enable: false + timeout: 5 + failedContinue: true + setMessageReactionExtensions: + enable: false + timeout: 5 + failedContinue: true + quitGroup: + enable: false + timeout: 5 + failedContinue: true + killGroupMember: + enable: false + timeout: 5 + failedContinue: true + dismissGroup: + enable: false + timeout: 5 + failedContinue: true + joinGroup: + enable: false + timeout: 5 + failedContinue: true + groupMsgRead: + enable: false + timeout: 5 + failedContinue: true + singleMsgRead: + enable: false + timeout: 5 + failedContinue: true + updateUserInfo: + enable: false + timeout: 5 + failedContinue: true + beforeUserRegister: + enable: false + timeout: 5 + failedContinue: true + afterUserRegister: + enable: false + timeout: 5 + failedContinue: true + transferGroupOwner: + enable: false + timeout: 5 + failedContinue: true + beforeSetFriendRemark: + enable: false + timeout: 5 + failedContinue: true + afterSetFriendRemark: + enable: false + timeout: 5 + failedContinue: true + afterGroupMsgRead: + enable: false + timeout: 5 + failedContinue: true + afterGroupMsgRevoke: + enable: false + timeout: 5 + failedContinue: true + afterJoinGroup: + enable: false + timeout: 5 + failedContinue: true + beforeInviteUserToGroup: + enable: false + timeout: 5 + failedContinue: true + joinGroupAfter: + enable: false + timeout: 5 + failedContinue: true + setGroupInfoAfter: + enable: false + timeout: 5 + failedContinue: true + setGroupInfoBefore: + enable: false + timeout: 5 + failedContinue: true + revokeMsgAfter: + enable: false + timeout: 5 + failedContinue: true + addBlackBefore: + enable: false + timeout: 5 + failedContinue: true + addFriendAfter: + enable: false + timeout: 5 + failedContinue: true + addFriendAgreeBefore: + enable: false + timeout: 5 + failedContinue: true + deleteFriendAfter: + enable: false + timeout: 5 + failedContinue: true + importFriendsBefore: + enable: false + timeout: 5 + failedContinue: true + importFriendsAfter: + enable: false + timeout: 5 + failedContinue: true + removeBlackAfter: + enable: false + timeout: 5 + failedContinue: true + +###################### Prometheus ###################### +# Prometheus configuration for various services +# The number of Prometheus ports per service needs to correspond to rpcPort +# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh +prometheus: + enable: true + grafanaUrl: http://127.0.0.1:13000/ + apiPrometheusPort: [20100] + userPrometheusPort: [ 20110 ] + friendPrometheusPort: [ 20120 ] + messagePrometheusPort: [ 20130 ] + messageGatewayPrometheusPort: [ 20140 ] + groupPrometheusPort: [ 20150 ] + authPrometheusPort: [ 20160 ] + pushPrometheusPort: [ 20170 ] + conversationPrometheusPort: [ 20230 ] + rtcPrometheusPort: [ 21300 ] + thirdPrometheusPort: [ 21301 ] + messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports From 309db2cb76768644e02fd7a55f60ef80a4efcd39 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:31:22 +0800 Subject: [PATCH 70/86] Script Refactoring --- scripts-new/lib/logging.sh | 4 +--- scripts-new/stop.sh | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index b2cf8e307..7e1cf9ba2 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -284,9 +284,7 @@ function openim::log::print_red() { echo -e "[$current_time] \033[0;31m$1\033[0m" } -function openim::log::print_red_two_lines() { - local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") - echo -e "[$current_time]" +function openim::log::print_red_no_time_stamp() { echo -e "\033[0;31m$1\033[0m" } diff --git a/scripts-new/stop.sh b/scripts-new/stop.sh index 9772b3cd0..878583db8 100644 --- a/scripts-new/stop.sh +++ b/scripts-new/stop.sh @@ -16,7 +16,7 @@ result=$(check_binaries_stop) ret_val=$? if [ $ret_val -ne 0 ]; then openim::log::print_red "Some services have not been stopped, details are as follows:" - openim::log::print_red_two_lines "$result" + openim::log::print_red_no_time_stamp "$result" exit 1 fi From cb75f2e9dc9e05c2632c2ca4de08c6f076fab4b6 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:34:38 +0800 Subject: [PATCH 71/86] Script Refactoring --- scripts-new/check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/check.sh b/scripts-new/check.sh index f245f339e..521f4d844 100644 --- a/scripts-new/check.sh +++ b/scripts-new/check.sh @@ -35,7 +35,7 @@ if [ $ret_val -eq 0 ]; then openim::log::print_green "All services are running normally." else openim::log::print_red "Some services are not running as expected. Details are as follows:" - openim::log::print_red_two_lines "$result" + openim::log::print_red_no_time_stamp "$result" exit 1 fi From 1600d1d2c173c042fdbc88c1abd52daff7278f75 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:02:21 +0800 Subject: [PATCH 72/86] Script Refactoring --- scripts-new/bricks.sh | 23 +++++++++++++++++++++++ scripts-new/define/binaries.sh | 2 ++ scripts-new/lib/path.sh | 5 +++++ scripts-new/start.sh | 11 +++++++++++ 4 files changed, 41 insertions(+) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 52a42613e..597d06f2a 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -32,6 +32,29 @@ start_binaries() { } +start_tools() { + # Assume tool_binaries=("ncpu" "infra") + for binary in "${tool_binaries[@]}"; do + local bin_full_path=$(get_tool_full_path "$binary") + # Assuming get_tool_full_path defines full path for each tool + cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG") + echo "Starting ${cmd[@]}" + "${cmd[@]}" + ret_val=$? + if [ $ret_val -eq 0 ]; then + echo "Started $bin_full_path successfully." + else + echo "Failed to start $bin_full_path with exit code $ret_val." + return 1 + fi + done + + return 0 +} + + + + #kill二进制全路径对应的进程 kill_exist_binaries(){ for binary in "${!binaries[@]}"; do diff --git a/scripts-new/define/binaries.sh b/scripts-new/define/binaries.sh index 9a8ca4a76..54f8912e0 100644 --- a/scripts-new/define/binaries.sh +++ b/scripts-new/define/binaries.sh @@ -7,3 +7,5 @@ declare -A binaries=( [openim-no-port]=2 ) + +tool_binaries=("ncpu" "infra") diff --git a/scripts-new/lib/path.sh b/scripts-new/lib/path.sh index 80cfb7e6d..5aea795fb 100644 --- a/scripts-new/lib/path.sh +++ b/scripts-new/lib/path.sh @@ -14,3 +14,8 @@ get_bin_full_path() { +get_tool_full_path() { + local tool_name="$1" + local tool_full_path="${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${bin_name}" + echo ${tool_full_path} +} diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 8ba1be2bf..d714510cb 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -12,6 +12,17 @@ source "$OPENIM_SCRIPTS/bricks.sh" # Main function to start binaries +result=$(start_tools) +ret_val=$? + + +if [ $ret_val -ne 0 ]; then + echo "tools start failed, abort start" + echo "$result" + exit 1 +fi + + kill_exist_binaries From b9d44bad6ff3c56a2738bae22e4004a0ae9d7c77 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:05:46 +0800 Subject: [PATCH 73/86] Script Refactoring --- scripts-new/bricks.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 597d06f2a..3ffe72ecc 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -35,6 +35,7 @@ start_binaries() { start_tools() { # Assume tool_binaries=("ncpu" "infra") for binary in "${tool_binaries[@]}"; do + echo $binary bbbbbbbbbbbbbb local bin_full_path=$(get_tool_full_path "$binary") # Assuming get_tool_full_path defines full path for each tool cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG") From a461f858da39c1fa32a066781847303fc469918b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:07:35 +0800 Subject: [PATCH 74/86] Script Refactoring --- scripts-new/lib/path.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/lib/path.sh b/scripts-new/lib/path.sh index 5aea795fb..4059fe1ce 100644 --- a/scripts-new/lib/path.sh +++ b/scripts-new/lib/path.sh @@ -16,6 +16,6 @@ get_bin_full_path() { get_tool_full_path() { local tool_name="$1" - local tool_full_path="${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${bin_name}" + local tool_full_path="${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${tool_name}" echo ${tool_full_path} } From 9cc62ddf044eb8b25b2dd86ba55127b02208e287 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:08:15 +0800 Subject: [PATCH 75/86] Script Refactoring --- scripts-new/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index d714510cb..709d9b027 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -22,7 +22,7 @@ if [ $ret_val -ne 0 ]; then exit 1 fi - + echo "$result" kill_exist_binaries From c7b91c188d61819e5e9f0af4492542d0874aa7ae Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:11:44 +0800 Subject: [PATCH 76/86] Script Refactoring --- scripts-new/bricks.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 3ffe72ecc..a4c38995f 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -35,17 +35,15 @@ start_binaries() { start_tools() { # Assume tool_binaries=("ncpu" "infra") for binary in "${tool_binaries[@]}"; do - echo $binary bbbbbbbbbbbbbb local bin_full_path=$(get_tool_full_path "$binary") - # Assuming get_tool_full_path defines full path for each tool cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG") echo "Starting ${cmd[@]}" - "${cmd[@]}" + result="${cmd[@]}" ret_val=$? if [ $ret_val -eq 0 ]; then - echo "Started $bin_full_path successfully." + echo "Started $bin_full_path successfully." $result else - echo "Failed to start $bin_full_path with exit code $ret_val." + echo "Failed to start $bin_full_path with exit code $ret_val." $result return 1 fi done From f8ccdbec7641371773f668b1db6bf7443e455fd8 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:14:11 +0800 Subject: [PATCH 77/86] Script Refactoring --- scripts-new/bricks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index a4c38995f..3025d4793 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -38,7 +38,7 @@ start_tools() { local bin_full_path=$(get_tool_full_path "$binary") cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG") echo "Starting ${cmd[@]}" - result="${cmd[@]}" + result=$( "${cmd[@]}" 2>&1 ) ret_val=$? if [ $ret_val -eq 0 ]; then echo "Started $bin_full_path successfully." $result From 432fffbe5dac7f01f91d78746ab034b443caa966 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:15:49 +0800 Subject: [PATCH 78/86] Script Refactoring --- scripts-new/bricks.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 3025d4793..c8d4f515b 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -38,12 +38,12 @@ start_tools() { local bin_full_path=$(get_tool_full_path "$binary") cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG") echo "Starting ${cmd[@]}" - result=$( "${cmd[@]}" 2>&1 ) + "${cmd[@]}" ret_val=$? if [ $ret_val -eq 0 ]; then - echo "Started $bin_full_path successfully." $result + echo "Started $bin_full_path successfully." else - echo "Failed to start $bin_full_path with exit code $ret_val." $result + echo "Failed to start $bin_full_path with exit code $ret_val." return 1 fi done From 2d3a8eebe5753a9ca4c16586693880b11f3540fa Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:17:09 +0800 Subject: [PATCH 79/86] Script Refactoring --- scripts-new/bricks.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index c8d4f515b..f6d4f9709 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -38,7 +38,9 @@ start_tools() { local bin_full_path=$(get_tool_full_path "$binary") cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG") echo "Starting ${cmd[@]}" - "${cmd[@]}" + #"${cmd[@]}" + "${cmd[@]}" >> "${LOG_FILE}" 2> >(tee -a "$ERR_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & + ret_val=$? if [ $ret_val -eq 0 ]; then echo "Started $bin_full_path successfully." From a1be9abd339013fbef267e72c2616d1272729c46 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:24:59 +0800 Subject: [PATCH 80/86] Script Refactoring --- scripts-new/bricks.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index f6d4f9709..c8d4f515b 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -38,9 +38,7 @@ start_tools() { local bin_full_path=$(get_tool_full_path "$binary") cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG") echo "Starting ${cmd[@]}" - #"${cmd[@]}" - "${cmd[@]}" >> "${LOG_FILE}" 2> >(tee -a "$ERR_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) & - + "${cmd[@]}" ret_val=$? if [ $ret_val -eq 0 ]; then echo "Started $bin_full_path successfully." From 4a6fd6261112a4de0554d4c9d37db4c79d91de8e Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:26:31 +0800 Subject: [PATCH 81/86] Script Refactoring --- scripts-new/start.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 709d9b027..4e7e7d9d7 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -22,7 +22,8 @@ if [ $ret_val -ne 0 ]; then exit 1 fi - echo "$result" +echo "all tools ok" +echo "$result" kill_exist_binaries From 1f084044031f6498dfc9997888f72ceb79d0ffca Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:32:08 +0800 Subject: [PATCH 82/86] Script Refactoring --- scripts-new/lib/logging.sh | 3 +++ scripts-new/start.sh | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index 7e1cf9ba2..cd388671d 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -288,6 +288,9 @@ function openim::log::print_red_no_time_stamp() { echo -e "\033[0;31m$1\033[0m" } +function openim::log::print_green_no_time_stamp() { + echo -e "\033[0;32m$1\033[0m" +} diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 4e7e7d9d7..e4566f1bd 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -14,16 +14,14 @@ source "$OPENIM_SCRIPTS/bricks.sh" result=$(start_tools) ret_val=$? - - if [ $ret_val -ne 0 ]; then - echo "tools start failed, abort start" - echo "$result" + openim::log::print_red "Some tools failed to start, details are as follows, abort start" + openim::log::print_red_no_time_stamp "$result" exit 1 fi -echo "all tools ok" -echo "$result" +openim::log::print_green "All tools executed successfully, details are as follows:" +openim::log::print_green_no_time_stamp "$result" kill_exist_binaries From 21a6fa2a3eb3db5a3a8d6ea65ef9fe43ba510148 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:35:48 +0800 Subject: [PATCH 83/86] Script Refactoring --- scripts-new/start.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index e4566f1bd..774aed195 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -21,7 +21,7 @@ if [ $ret_val -ne 0 ]; then fi openim::log::print_green "All tools executed successfully, details are as follows:" -openim::log::print_green_no_time_stamp "$result" +echo "$result" kill_exist_binaries @@ -29,8 +29,8 @@ result=$(check_binaries_stop) ret_val=$? if [ $ret_val -ne 0 ]; then - echo "$result" - echo "Some services running, abort start" + openim::log::print_red "Some services running, details are as follows, abort start" + openim::log::print_red_no_time_stamp "$result" exit 1 fi From f2ef60f6677979107651a16486a5a87c332f6766 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:39:40 +0800 Subject: [PATCH 84/86] Script Refactoring --- scripts-new/start.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 774aed195..391c7f74c 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -11,6 +11,7 @@ source "$OPENIM_SCRIPTS/bricks.sh" # Main function to start binaries +openim::log::print_blue "Starting tools" result=$(start_tools) ret_val=$? @@ -20,16 +21,19 @@ if [ $ret_val -ne 0 ]; then exit 1 fi -openim::log::print_green "All tools executed successfully, details are as follows:" echo "$result" + +openim::log::print_green "All tools executed successfully" +openim::log::print_blue "Starting services" + kill_exist_binaries result=$(check_binaries_stop) ret_val=$? if [ $ret_val -ne 0 ]; then - openim::log::print_red "Some services running, details are as follows, abort start" + openim::log::print_red "Some services running, details are as follows, abort start" openim::log::print_red_no_time_stamp "$result" exit 1 fi From d62c6d38ce086a0aeed3b7569b696fb3a49b2056 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:42:22 +0800 Subject: [PATCH 85/86] Script Refactoring --- scripts-new/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 391c7f74c..e9e196808 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -11,7 +11,7 @@ source "$OPENIM_SCRIPTS/bricks.sh" # Main function to start binaries -openim::log::print_blue "Starting tools" +openim::log::print_blue "Starting tools: Please wait as we initiate the necessary tools required for the operation. This process may take a few moments depending on the number and the complexity of the tools being started. You will be notified upon successful completion of each tool startup, or informed of any issues should they arise. Thank you for your patience." result=$(start_tools) ret_val=$? @@ -25,7 +25,7 @@ echo "$result" openim::log::print_green "All tools executed successfully" -openim::log::print_blue "Starting services" +openim::log::print_blue "Starting services. Please wait as we initiate the necessary system services. This process may take a few moments" kill_exist_binaries From b306c715f8c547821b5111a6a8ac4ac0bfdbb0f5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 18:45:24 +0800 Subject: [PATCH 86/86] Script Refactoring --- scripts-new/start.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts-new/start.sh b/scripts-new/start.sh index e9e196808..1d30dcbbc 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -11,7 +11,9 @@ source "$OPENIM_SCRIPTS/bricks.sh" # Main function to start binaries -openim::log::print_blue "Starting tools: Please wait as we initiate the necessary tools required for the operation. This process may take a few moments depending on the number and the complexity of the tools being started. You will be notified upon successful completion of each tool startup, or informed of any issues should they arise. Thank you for your patience." +openim::log::print_blue "Starting tools primarily involves component verification and other preparatory tasks." + + result=$(start_tools) ret_val=$? @@ -25,7 +27,7 @@ echo "$result" openim::log::print_green "All tools executed successfully" -openim::log::print_blue "Starting services. Please wait as we initiate the necessary system services. This process may take a few moments" +openim::log::print_blue "Starting services involves multiple RPCs and API and may take some time. Please be patient" kill_exist_binaries