From 38f685bd01b793d49d5d4e1cdc9b95500662dedf Mon Sep 17 00:00:00 2001
From: skiffer-git <72860476+skiffer-git@users.noreply.github.com>
Date: Thu, 7 Mar 2024 12:24:45 +0800
Subject: [PATCH 1/7] Optimizing Docker Log Output Detection (#2014)
* Optimize script logs
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
---
scripts/check-all.sh | 5 +++++
scripts/docker-start-all.sh | 10 +---------
scripts/lib/logging.sh | 6 ++++++
scripts/start-all.sh | 8 ++++++++
4 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/scripts/check-all.sh b/scripts/check-all.sh
index a9b07d65b..1d05f838b 100755
--- a/scripts/check-all.sh
+++ b/scripts/check-all.sh
@@ -26,6 +26,11 @@
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/install/common.sh"
+if grep -q docker /proc/1/cgroup; then
+ exec > ${DOCKER_LOG_FILE} 2>&1
+fi
+
+
OPENIM_VERBOSE=4
openim::log::info "\n# Begin to check all openim service"
diff --git a/scripts/docker-start-all.sh b/scripts/docker-start-all.sh
index c47069e3b..4c9b7308f 100755
--- a/scripts/docker-start-all.sh
+++ b/scripts/docker-start-all.sh
@@ -23,15 +23,7 @@
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/install/common.sh"
-
openim::log::info "\n# Use Docker to start all openim service"
-
trap 'openim::util::onCtrlC' INT
-
"${OPENIM_ROOT}"/scripts/start-all.sh
-
-sleep 5
-
-"${OPENIM_ROOT}"/scripts/check-all.sh
-
-tail -f ${LOG_FILE}
+tail -f ${DOCKER_LOG_FILE}
diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh
index 8d017b077..0d5113541 100755
--- a/scripts/lib/logging.sh
+++ b/scripts/lib/logging.sh
@@ -36,6 +36,12 @@ if [[ ! -d "${OPENIM_OUTPUT}/logs" ]]; then
touch "$TMP_LOG_FILE"
fi
+if [[ ! -f "$DOCKER_LOG_FILE" ]]; then
+ touch "$DOCKER_LOG_FILE"
+fi
+
+
+
# Define the logging function
function echo_log() {
if $ENABLE_LOGGING; then
diff --git a/scripts/start-all.sh b/scripts/start-all.sh
index c27f2010c..fcf9496cc 100755
--- a/scripts/start-all.sh
+++ b/scripts/start-all.sh
@@ -17,12 +17,17 @@
#FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array.
+#!/bin/bash
+
+
+
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/install/common.sh"
+
# Function to execute the scripts.
function execute_start_scripts() {
for script_path in "${OPENIM_SERVER_SCRIPT_START_LIST[@]}"; do
@@ -57,6 +62,9 @@ function execute_start_scripts() {
+if grep -q docker /proc/1/cgroup; then
+ exec > ${DOCKER_LOG_FILE} 2>&1
+fi
From 39647b33da1224ce12c894c3ed2d1249a0498862 Mon Sep 17 00:00:00 2001
From: skiffer-git <72860476+skiffer-git@users.noreply.github.com>
Date: Thu, 7 Mar 2024 15:40:25 +0800
Subject: [PATCH 2/7] Optimizing Docker Log Output (#2018)
* Optimize script logs
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
---
scripts/check-all.sh | 6 +++---
scripts/lib/logging.sh | 2 +-
scripts/lib/util.sh | 9 +++++++++
scripts/start-all.sh | 2 +-
4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/scripts/check-all.sh b/scripts/check-all.sh
index 1d05f838b..8e89af79d 100755
--- a/scripts/check-all.sh
+++ b/scripts/check-all.sh
@@ -26,8 +26,8 @@
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/install/common.sh"
-if grep -q docker /proc/1/cgroup; then
- exec > ${DOCKER_LOG_FILE} 2>&1
+if openim::util::is_running_in_container; then
+ exec >> ${DOCKER_LOG_FILE} 2>&1
fi
@@ -75,7 +75,7 @@ if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then
openim::color::echo ${COLOR_CYAN} "Environment in the interior of the container"
else
openim::color::echo ${COLOR_CYAN} "The environment is outside the container"
- openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]} || return 0
+ openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}
fi
if [[ $? -ne 0 ]]; then
diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh
index 0d5113541..fec71b19d 100755
--- a/scripts/lib/logging.sh
+++ b/scripts/lib/logging.sh
@@ -28,7 +28,7 @@ fi
LOG_FILE="${OPENIM_OUTPUT}/logs/openim-$(date '+%Y%m%d').log"
STDERR_LOG_FILE="${OPENIM_OUTPUT}/logs/openim-error-$(date '+%Y%m%d').log"
TMP_LOG_FILE="${OPENIM_OUTPUT}/logs/openim-tmp-$(date '+%Y%m%d').log"
-
+DOCKER_LOG_FILE="${OPENIM_OUTPUT}/logs/openim-docker.log"
if [[ ! -d "${OPENIM_OUTPUT}/logs" ]]; then
mkdir -p "${OPENIM_OUTPUT}/logs"
touch "$LOG_FILE"
diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh
index d84562c1d..e9908ae66 100755
--- a/scripts/lib/util.sh
+++ b/scripts/lib/util.sh
@@ -2866,6 +2866,15 @@ function openim::util::gen_os_arch() {
+function openim::util::is_running_in_container() {
+ if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+
function openim::util::check_process_names_for_stop() {
local all_stopped=true
for service in "${OPENIM_ALL_SERVICE_LIBRARIES[@]}"; do
diff --git a/scripts/start-all.sh b/scripts/start-all.sh
index fcf9496cc..419c16628 100755
--- a/scripts/start-all.sh
+++ b/scripts/start-all.sh
@@ -62,7 +62,7 @@ function execute_start_scripts() {
-if grep -q docker /proc/1/cgroup; then
+if openim::util::is_running_in_container; then
exec > ${DOCKER_LOG_FILE} 2>&1
fi
From a84162815a1c56edcda80d13ada7bed37e96a34e Mon Sep 17 00:00:00 2001
From: OpenIM Bot <124379614+kubbot@users.noreply.github.com>
Date: Thu, 7 Mar 2024 19:38:20 +0800
Subject: [PATCH 3/7] cicd: bump League Patch (#2012)
---
internal/rpc/third/third.go | 2 +-
pkg/common/db/mgo/object.go | 2 +-
pkg/rpcclient/msg.go | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/internal/rpc/third/third.go b/internal/rpc/third/third.go
index 5f6fc6c34..928fb0f42 100644
--- a/internal/rpc/third/third.go
+++ b/internal/rpc/third/third.go
@@ -17,12 +17,12 @@ package third
import (
"context"
"fmt"
- "github.com/OpenIMSDK/tools/errs"
"net/url"
"time"
"github.com/OpenIMSDK/protocol/third"
"github.com/OpenIMSDK/tools/discoveryregistry"
+ "github.com/OpenIMSDK/tools/errs"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/controller"
diff --git a/pkg/common/db/mgo/object.go b/pkg/common/db/mgo/object.go
index a527fa60d..e9d639f19 100644
--- a/pkg/common/db/mgo/object.go
+++ b/pkg/common/db/mgo/object.go
@@ -16,8 +16,8 @@ package mgo
import (
"context"
- "github.com/OpenIMSDK/tools/errs"
+ "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mgoutil"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
"go.mongodb.org/mongo-driver/bson"
diff --git a/pkg/rpcclient/msg.go b/pkg/rpcclient/msg.go
index 4daf897a1..54a4671a3 100644
--- a/pkg/rpcclient/msg.go
+++ b/pkg/rpcclient/msg.go
@@ -18,16 +18,16 @@ import (
"context"
"encoding/json"
"fmt"
- "github.com/OpenIMSDK/tools/errs"
- util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/discoveryregistry"
+ "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/utils"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
+ util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
)
From a1f0eb2e3eb49551ddc6e1a757f6e8c6d74a45ee Mon Sep 17 00:00:00 2001
From: skiffer-git <72860476+skiffer-git@users.noreply.github.com>
Date: Fri, 8 Mar 2024 08:56:22 +0800
Subject: [PATCH 4/7] Exit with code 1 when the check script fails (#2022)
* Optimize script logs
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Optimizing Docker Log Output Detection
* Exit with code 1 when the check script fails
---
scripts/check-all.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/check-all.sh b/scripts/check-all.sh
index 8e89af79d..d41023384 100755
--- a/scripts/check-all.sh
+++ b/scripts/check-all.sh
@@ -104,6 +104,7 @@ if [[ $? -ne 0 ]]; then
echo "+++ cat openim log file >>> ${LOG_FILE}"
openim::log::error "check process failed.\n "
echo "$result"
+ exit 1
else
openim::log::success "All openim services are running normally! "
fi
From a93615d3e0645cf45931ab299d6b51691e6d1f30 Mon Sep 17 00:00:00 2001
From: OpenIM Bot <124379614+kubbot@users.noreply.github.com>
Date: Fri, 8 Mar 2024 10:28:48 +0800
Subject: [PATCH 5/7] cicd: bump League Patch (#2025)
---
CHANGELOG/CHANGELOG-3.6.md | 20 ++++++++++++++++++++
pkg/common/config/version | 2 +-
2 files changed, 21 insertions(+), 1 deletion(-)
create mode 100644 CHANGELOG/CHANGELOG-3.6.md
diff --git a/CHANGELOG/CHANGELOG-3.6.md b/CHANGELOG/CHANGELOG-3.6.md
new file mode 100644
index 000000000..214d58340
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-3.6.md
@@ -0,0 +1,20 @@
+# Version logging for OpenIM
+
+
+
+
+
+
+## [Unreleased]
+
+
+
+## v3.6.0 - 2024-03-07
+### Reverts
+- update etcd to v3.5.2 ([#206](https://github.com/openimsdk/open-im-server/issues/206))
+
+### Pull Requests
+- Merge branch 'tuoyun'
+
+
+[Unreleased]: https://github.com/openimsdk/open-im-server/compare/v3.6.0...HEAD
diff --git a/pkg/common/config/version b/pkg/common/config/version
index d5c0c9914..40c341bdc 100644
--- a/pkg/common/config/version
+++ b/pkg/common/config/version
@@ -1 +1 @@
-3.5.1
+3.6.0
From 42482e7eb45cf01a54fc5b4051503c8f31d33509 Mon Sep 17 00:00:00 2001
From: skiffer-git <72860476+skiffer-git@users.noreply.github.com>
Date: Fri, 8 Mar 2024 12:19:04 +0800
Subject: [PATCH 6/7] Execute after the component check succeeds &&
minio.Enable is not configured to use MinIO (#2026)
* Exit with code 1 when the check script fails
* Exit with code 1 when the check script fails
* Exit with code 1 when the check script fails
* Exit with code 1 when the check script fails
* Handle the return value of pre-start
* Handle the return value of pre-start
* Handle the return value of pre-start
* minio.Enable is not configured to use MinIO, therefore the image server is not checked
* minio.Enable is not configured to use MinIO, therefore the image server is not checked
* minio.Enable is not configured to use MinIO, therefore the image server is not checked
* minio.Enable is not configured to use MinIO, therefore the image server is not checked
---
scripts/install/openim-tools.sh | 25 +++++++++++++++++++------
scripts/start-all.sh | 12 ++++++++++--
tools/component/component.go | 26 ++++++++++++++++++++++----
3 files changed, 51 insertions(+), 12 deletions(-)
diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh
index 4eb722c6e..003264221 100755
--- a/scripts/install/openim-tools.sh
+++ b/scripts/install/openim-tools.sh
@@ -101,7 +101,16 @@ function openim::tools::start_service() {
cmd="${cmd} --prometheus_port ${prometheus_port}"
fi
openim::log::status "Starting binary ${binary_name}..."
- ${cmd} | tee -a "${LOG_FILE}"
+ ${cmd} >>"${LOG_FILE}" 2> >(tee -a "${LOG_FILE}" >&2)
+ local status=$?
+
+ if [ $status -eq 0 ]; then
+ openim::log::info "Service ${binary_name} started successfully."
+ return 0
+ else
+ openim::log::error "Failed to start service ${binary_name}."
+ return 1
+ fi
}
function openim::tools::start() {
@@ -115,11 +124,15 @@ function openim::tools::start() {
function openim::tools::pre-start() {
- openim::log::info "Preparing to start OpenIM Tools..."
- for tool in "${OPENIM_TOOLS_PRE_START_NAME_LISTARIES[@]}"; do
- openim::log::info "Starting tool ${tool}..."
- openim::tools::start_service ${tool} ${OPNEIM_CONFIG}
- done
+ openim::log::info "Preparing to start OpenIM Tools..."
+ for tool in "${OPENIM_TOOLS_PRE_START_NAME_LISTARIES[@]}"; do
+ openim::log::info "Starting tool ${tool}..."
+ if ! openim::tools::start_service ${tool} ${OPNEIM_CONFIG}; then
+ openim::log::error "Failed to start ${tool}, aborting..."
+ return 1
+ fi
+ done
+ openim::log::info "All tools started successfully."
}
function openim::tools::post-start() {
diff --git a/scripts/start-all.sh b/scripts/start-all.sh
index 419c16628..aac4b1837 100755
--- a/scripts/start-all.sh
+++ b/scripts/start-all.sh
@@ -83,10 +83,18 @@ fi
# TODO Prelaunch tools, simple for now, can abstract functions later
TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh
-openim::log::status "\n## Pre Starting OpenIM services"
-${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start
+openim::log::print_blue "\n## Pre Starting OpenIM services"
+
+if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then
+ openim::log::error "Pre Starting OpenIM services failed, aborting..."
+ exit 1
+fi
+
+
+openim::log::print_blue "Pre Starting OpenIM services processed successfully"
+
result=$("${OPENIM_ROOT}"/scripts/stop-all.sh)
if [[ $? -ne 0 ]]; then
openim::log::error "View the error logs from this startup. ${LOG_FILE} \n"
diff --git a/tools/component/component.go b/tools/component/component.go
index 34d3dff6b..e3b5b1956 100644
--- a/tools/component/component.go
+++ b/tools/component/component.go
@@ -102,7 +102,14 @@ func main() {
if !check.flag {
err = check.function(check.config)
if err != nil {
- allSuccess = false
+ if errors.Is(err, errMinioNotEnabled) {
+ fmt.Println(err.Error())
+ checks[index].flag = true
+ }
+ if errors.Is(err, errSignEndPoint) {
+ fmt.Fprintf(os.Stderr, err.Error())
+ checks[index].flag = true
+ }
component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, errs.Unwrap(err).Error()))
if !strings.Contains(errs.Unwrap(err).Error(), "connection refused") &&
!strings.Contains(errs.Unwrap(err).Error(), "timeout waiting") {
@@ -125,6 +132,11 @@ func main() {
os.Exit(-1)
}
+var errMinioNotEnabled = errors.New("minio.Enable is not configured to use MinIO")
+
+var errSignEndPoint = errors.New("minio.signEndPoint contains 127.0.0.1, causing issues with image sending")
+var errApiURL = errors.New("object.apiURL contains 127.0.0.1, causing issues with image sending")
+
// checkMongo checks the MongoDB connection without retries
func checkMongo(config *config.GlobalConfig) error {
mongoStu := &component.Mongo{
@@ -153,10 +165,16 @@ func checkRedis(config *config.GlobalConfig) error {
// checkMinio checks the MinIO connection
func checkMinio(config *config.GlobalConfig) error {
- // Check if MinIO is enabled
- if config.Object.Enable != "minio" {
- return errs.Wrap(errors.New("minio.Enable is empty"))
+ if strings.Contains(config.Object.ApiURL, "127.0.0.1") {
+ return errs.Wrap(errApiURL, "config.Object.ApiURL: "+config.Object.ApiURL)
}
+ if config.Object.Enable != "minio" {
+ return errs.Wrap(errMinioNotEnabled, "config.Object.Enable: "+config.Object.Enable)
+ }
+ if strings.Contains(config.Object.Minio.Endpoint, "127.0.0.1") {
+ return errs.Wrap(errSignEndPoint, "config.Object.Minio.Endpoint: "+config.Object.Minio.Endpoint)
+ }
+
minio := &component.Minio{
ApiURL: config.Object.ApiURL,
Endpoint: config.Object.Minio.Endpoint,
From 16799648dc6d278b1706d4a0c78640097a7d862f Mon Sep 17 00:00:00 2001
From: skiffer-git <72860476+skiffer-git@users.noreply.github.com>
Date: Fri, 8 Mar 2024 14:06:27 +0800
Subject: [PATCH 7/7] del log (#2030)
---
scripts/install/openim-tools.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh
index 003264221..04cd70adf 100755
--- a/scripts/install/openim-tools.sh
+++ b/scripts/install/openim-tools.sh
@@ -101,7 +101,7 @@ function openim::tools::start_service() {
cmd="${cmd} --prometheus_port ${prometheus_port}"
fi
openim::log::status "Starting binary ${binary_name}..."
- ${cmd} >>"${LOG_FILE}" 2> >(tee -a "${LOG_FILE}" >&2)
+ ${cmd}
local status=$?
if [ $status -eq 0 ]; then