diff --git a/.github/workflows/openimci.yml b/.github/workflows/openimci.yml index 5f010db8a..d65c0dc89 100644 --- a/.github/workflows/openimci.yml +++ b/.github/workflows/openimci.yml @@ -130,14 +130,14 @@ jobs: sudo make install execute-scripts: - name: Execute OpenIM script on ${{ matrix.os }} + name: Execute OpenIM Script On ${{ matrix.os }} runs-on: ${{ matrix.os }} environment: name: openim strategy: matrix: go_version: ["1.20"] - os: ["ubuntu-latest"] + os: ["ubuntu-latest", "macos-latest"] steps: - name: Checkout code uses: actions/checkout@v4 @@ -154,18 +154,52 @@ jobs: version: '3.x' # If available, use the latest major version that's compatible repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Docker Operations + # - name: Install latest Bash (macOS only) + # if: runner.os == 'macOS' + # run: | + # /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + # brew update + + # brew install bash + # brew install gnu-sed + + # echo "/usr/local/bin" >> $GITHUB_PATH + # echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH + # continue-on-error: true + + - name: Set up Docker for Ubuntu + if: runner.os == 'Linux' run: | sudo make init sudo docker compose up -d sudo sleep 20 - - name: Module Operations + # - name: Set up Docker for macOS + # if: runner.os == 'macOS' + # run: | + # brew install --cask docker + # open /Applications/Docker.app + + # sleep 10 + # docker-compose --version || brew install docker-compose + + # docker-compose up -d + # sleep 20 + + - name: Module Operations for Ubuntu + if: runner.os == 'Linux' run: | sudo make tidy sudo make tools.verify.go-gitlint - - name: Build, Start, Check Services and Print Logs + # - name: Module Operations for macOS + # if: runner.os == 'macOS' + # run: | + # make tidy + # make tools.verify.go-gitlint + + - name: Build, Start, Check Services and Print Logs for Ubuntu + if: runner.os == 'Linux' run: | sudo make init && \ sudo make build && \ @@ -173,6 +207,15 @@ jobs: sudo make check || \ (echo "An error occurred, printing logs:" && sudo cat ./_output/logs/* 2>/dev/null) + # - name: Build, Start, Check Services and Print Logs for macOS + # if: runner.os == 'macOS' + # run: | + # make init && \ + # make build && \ + # make start && \ + # make check || \ + # (echo "An error occurred, printing logs:" && sudo cat ./_output/logs/* 2>/dev/null) + openim-test-build-image: name: Build OpenIM Docker Image runs-on: ubuntu-latest diff --git a/config/templates/config.yaml.template b/config/templates/config.yaml.template index 64a274b56..fd51a2e31 100644 --- a/config/templates/config.yaml.template +++ b/config/templates/config.yaml.template @@ -122,14 +122,14 @@ api: # minio.signEndpoint is minio public network address object: enable: "minio" - apiURL: "http://172.28.0.1:10002" + apiURL: "http://14.155.64.202:10002" minio: bucket: "openim" endpoint: "http://172.28.0.1:10005" accessKeyID: "root" secretAccessKey: "openIM123" sessionToken: '' - signEndpoint: "http://172.28.0.1:10005" + signEndpoint: "http://14.155.64.202:10005" publicRead: false cos: bucketURL: https://temp-1252357374.cos.ap-chengdu.myqcloud.com @@ -193,7 +193,7 @@ rpcRegisterName: # Whether to output in json format # Whether to include stack trace in logs log: - storageLocation: ../logs/ + storageLocation: /data/workspaces/open-im-server/logs/ rotationTime: 24 remainRotationCount: 2 remainLogLevel: 6 diff --git a/config/templates/env.template b/config/templates/env.template index f3ca987ce..ffcec89e5 100644 --- a/config/templates/env.template +++ b/config/templates/env.template @@ -26,11 +26,11 @@ PASSWORD=openIM123 # Base URL for the application programming interface (API). # Default: API_URL=http://172.28.0.1:10002 -API_URL=http://172.28.0.1:10002 +API_URL=http://14.155.64.202:10002 # Directory path for storing data files or related information. # Default: DATA_DIR=./ -DATA_DIR=./ +DATA_DIR=/data/workspaces/open-im-server # Choose the appropriate image address, the default is GITHUB image, # you can choose docker hub, for Chinese users can choose Ali Cloud @@ -210,8 +210,9 @@ API_OPENIM_PORT=10002 # ====================================== # Branch name for OpenIM chat. -# Default: CHAT_BRANCH=main -CHAT_BRANCH=main +# Default: CHAT_IMAGE_VERSION=main +# https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/version.md +CHAT_IMAGE_VERSION=main # Address or hostname for the OpenIM chat service. # Default: OPENIM_CHAT_ADDRESS=172.28.0.1 @@ -231,8 +232,8 @@ OPENIM_CHAT_DATA_DIR=./openim-chat/main # ====================================== # Branch name for OpenIM server. -# Default: SERVER_BRANCH=main -SERVER_BRANCH=main +# Default: SERVER_IMAGE_VERSION=main +SERVER_IMAGE_VERSION=main # Port for the OpenIM admin API. # Default: OPENIM_ADMIN_API_PORT=10009 diff --git a/deployments/templates/env-template.yaml b/deployments/templates/env-template.yaml index d343e047f..ab9c87c02 100644 --- a/deployments/templates/env-template.yaml +++ b/deployments/templates/env-template.yaml @@ -210,8 +210,8 @@ API_OPENIM_PORT=${API_OPENIM_PORT} # ====================================== # Branch name for OpenIM chat. -# Default: CHAT_BRANCH=main -CHAT_BRANCH=${CHAT_BRANCH} +# Default: CHAT_IMAGE_VERSION=main +CHAT_IMAGE_VERSION=${CHAT_IMAGE_VERSION} # Address or hostname for the OpenIM chat service. # Default: OPENIM_CHAT_ADDRESS=172.28.0.1 @@ -231,8 +231,8 @@ OPENIM_CHAT_DATA_DIR=${OPENIM_CHAT_DATA_DIR} # ====================================== # Branch name for OpenIM server. -# Default: SERVER_BRANCH=main -SERVER_BRANCH=${SERVER_BRANCH} +# Default: SERVER_IMAGE_VERSION=main +SERVER_IMAGE_VERSION=${SERVER_IMAGE_VERSION} # Port for the OpenIM admin API. # Default: OPENIM_ADMIN_API_PORT=10009 diff --git a/docs/contrib/environment.md b/docs/contrib/environment.md index 3dd090dcc..310c2df6a 100644 --- a/docs/contrib/environment.md +++ b/docs/contrib/environment.md @@ -104,18 +104,18 @@ Docker deployment offers a slightly more intricate template. Within the [openim- Configuration file modifications can be made by specifying corresponding environment variables, for instance: ```bash -export CHAT_BRANCH="main" -export SERVER_BRANCH="main" +export CHAT_IMAGE_VERSION="main" +export SERVER_IMAGE_VERSION="main" ``` These variables are stored within the [`environment.sh`](https://github.com/OpenIMSDK/openim-docker/blob/main/scripts/install/environment.sh) configuration: ```bash -readonly CHAT_BRANCH=${CHAT_BRANCH:-'main'} -readonly SERVER_BRANCH=${SERVER_BRANCH:-'main'} +readonly CHAT_IMAGE_VERSION=${CHAT_IMAGE_VERSION:-'main'} +readonly SERVER_IMAGE_VERSION=${SERVER_IMAGE_VERSION:-'main'} ``` -Setting a variable, e.g., `export CHAT_BRANCH="release-v1.3"`, will prioritize `CHAT_BRANCH="release-v1.3"` as the variable value. Ultimately, the chosen image version is determined, and rendering is achieved through `make init` (or `./scripts/init-config.sh`). +Setting a variable, e.g., `export CHAT_IMAGE_VERSION="release-v1.3"`, will prioritize `CHAT_IMAGE_VERSION="release-v1.3"` as the variable value. Ultimately, the chosen image version is determined, and rendering is achieved through `make init` (or `./scripts/init-config.sh`). > Note: Direct modifications to the `config.yaml` file are also permissible without utilizing `make init`. diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index e8e4dad92..2c3c6fc43 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -279,7 +279,6 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR break } } - s.Notification.GroupCreatedNotification(ctx, tips) if req.GroupInfo.GroupType == constant.SuperGroup { go func() { for _, userID := range userIDs { diff --git a/pkg/common/discoveryregister/discoveryregister.go b/pkg/common/discoveryregister/discoveryregister.go index c14323027..761ab1a13 100644 --- a/pkg/common/discoveryregister/discoveryregister.go +++ b/pkg/common/discoveryregister/discoveryregister.go @@ -39,4 +39,3 @@ func NewDiscoveryRegister(envType string) (discoveryregistry.SvcDiscoveryRegistr default: return nil, errors.New("envType not correct") } -} diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 338152d20..30a4e422b 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -47,7 +47,6 @@ print_services_and_ports() { echo "+-------------------------+----------+" } - # Print out services and their ports print_services_and_ports OPENIM_SERVER_NAME_TARGETS OPENIM_SERVER_PORT_TARGETS diff --git a/scripts/init-config.sh b/scripts/init-config.sh index 8dba7312a..c75fc5502 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - # This script automatically initializes various configuration files and can generate example files. set -o errexit @@ -169,12 +168,6 @@ process_file() { sleep 0.5 } -declare -A env_vars=( - ["OPENIM_IP"]="172.28.0.1" - ["DATA_DIR"]="./" - ["LOG_STORAGE_LOCATION"]="../logs/" -) - clean_config_files() { local all_templates=("${TEMPLATES[@]}" "${COPY_TEMPLATES[@]}") diff --git a/scripts/install/environment.sh b/scripts/install/environment.sh index 643f621b6..3dd062af6 100755 --- a/scripts/install/environment.sh +++ b/scripts/install/environment.sh @@ -66,8 +66,8 @@ def "ENV_FILE" ""${OPENIM_ROOT}"/scripts/install/environment.sh" ###################### Docker compose ################### # OPENIM AND CHAT -def "CHAT_BRANCH" "main" -def "SERVER_BRANCH" "main" +def "CHAT_IMAGE_VERSION" "main" +def "SERVER_IMAGE_VERSION" "main" # Choose the appropriate image address, the default is GITHUB image, # you can choose docker hub, for Chinese users can choose Ali Cloud @@ -139,7 +139,7 @@ readonly API_OPENIM_PORT=${API_OPENIM_PORT:-'10002'} def "API_LISTEN_IP" "0.0.0.0" # API的监听IP ###################### openim-chat 配置信息 ###################### -def "OPENIM_CHAT_DATA_DIR" "./openim-chat/${CHAT_BRANCH}" +def "OPENIM_CHAT_DATA_DIR" "./openim-chat/${CHAT_IMAGE_VERSION}" def "OPENIM_CHAT_ADDRESS" "${DOCKER_BRIDGE_GATEWAY}" # OpenIM服务地址 def "OPENIM_CHAT_API_PORT" "10008" # OpenIM API端口 def "CHAT_API_LISTEN_IP" "" # OpenIM API的监听IP diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 9d28aa284..8e7d5b09a 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -20,7 +20,7 @@ OPENIM_VERBOSE="${OPENIM_VERBOSE:-5}" ENABLE_LOGGING="${ENABLE_LOGGING:-true}" # If OPENIM_OUTPUT is not set, set it to the default value -if [[ ! -v OPENIM_OUTPUT ]]; then +if [ -z "${OPENIM_OUTPUT+x}" ]; then OPENIM_OUTPUT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../_output" && pwd -P)" fi diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index ad3baa6bf..b8d76edeb 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -302,8 +302,12 @@ openim::util::check_ports() { # Iterate over each given port. for port in "$@"; do # Use the `ss` command to find process information related to the given port. - local info=$(ss -ltnp | grep ":$port" || true) - + if command -v ss > /dev/null 2>&1; then + info=$(ss -ltnp | grep ":$port" || true) + else + info=$(netstat -ltnp | grep ":$port" || true) + fi + # If there's no process information, it means the process associated with the port is not running. if [[ -z $info ]]; then not_started+=($port) @@ -364,6 +368,18 @@ openim::util::check_ports() { # 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 command -v ss > /dev/null 2>&1; then + # used ss comment + ss -ltnp 2>/dev/null | grep $pid | awk '{print $4}' | cut -d ':' -f2 + else + # used netstat comment replace ss + netstat -ltnp 2>/dev/null | grep $pid | awk '{print $4}' | sed 's/.*://' + fi + } + # Arrays to collect details of processes local not_started=() local started=() @@ -382,7 +398,7 @@ openim::util::check_process_names() { for pid in "${pids[@]}"; do local command=$(ps -p $pid -o cmd=) local start_time=$(ps -p $pid -o lstart=) - local port=$(ss -ltnp 2>/dev/null | grep $pid | awk '{print $4}' | cut -d ':' -f2) + local port=$(get_port $pid) # Check if port information was found for the PID if [[ -z $port ]]; then @@ -419,6 +435,7 @@ openim::util::check_process_names() { return 0 fi } + # openim::util::check_process_names docker-pr # The `openim::util::stop_services_on_ports` function stops services running on specified ports.