diff --git a/README-zh_CN.md b/README-zh_CN.md
index 9234666f4..8addfe20a 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -98,6 +98,11 @@ OpenIM 我们的目标是建立一个顶级的开源社区。我们有一套标
+ [接口标准](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/interface.md)
++ [OpenIM配置和环境变量设置](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md)
+
+> **Note**
+> 针对中国的用户,阅读我们的 [Docker 镜像标准](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md) 以便使用国内 aliyun 的镜像地址。OpenIM 也有针对中国的 gitee 同步仓库,你可以在 [gitee.com](https://gitee.com/openimsdk) 上找到它。
+
## :link: 链接
+ **[完整文档](https://doc.rentsoft.cn/)**
diff --git a/README.md b/README.md
index 30499824c..f58625fb0 100644
--- a/README.md
+++ b/README.md
@@ -212,6 +212,8 @@ Before you start, please make sure your changes are in demand. The best for that
- [Interface Standards](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/api.md)
- [Log Standards](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/logging.md)
- [Error Code Standards](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/error_code.md)
+- [OpenIM configuration and environment variable Settings](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md)
+
## :busts_in_silhouette: Community
diff --git a/docs/contrib/environment.md b/docs/contrib/environment.md
index 2c0646bee..6efddafd3 100644
--- a/docs/contrib/environment.md
+++ b/docs/contrib/environment.md
@@ -38,6 +38,38 @@
* 2.20.1. [General Configuration](#GeneralConfiguration)
* 2.20.2. [Service-Specific Prometheus Ports](#Service-SpecificPrometheusPorts)
+## 0. OpenIM Config File
+
+Ensuring that OpenIM operates smoothly requires clear direction on the configuration file's location. Here's a detailed step-by-step guide on how to provide this essential path to OpenIM:
+
+1. **Using the Command-line Argument**:
+
+ + **For Configuration Path**: When initializing OpenIM, you can specify the path to the configuration file directly using the `-c` or `--config_folder_path` option.
+
+ ```bash
+ ❯ _output/bin/platforms/linux/amd64/openim-api --config_folder_path="/your/config/folder/path"
+ ```
+
+ + **For Port Specification**: Similarly, if you wish to designate a particular port, utilize the `-p` option followed by the desired port number.
+
+ ```bash
+ ❯ _output/bin/platforms/linux/amd64/openim-api -p 1234
+ ```
+
+ Note: If the port is not specified here, OpenIM will fetch it from the configuration file. Setting the port via environment variables isn't supported. We recommend consolidating settings in the configuration file for a more consistent and streamlined setup.
+
+2. **Leveraging the Environment Variable**:
+
+ You have the flexibility to determine OpenIM's configuration path by setting an `OPENIMCONFIG` environment variable. This method provides a seamless way to instruct OpenIM without command-line parameters every time.
+
+ ```bash
+ export OPENIMCONFIG="/path/to/your/config"
+ ```
+
+3. **Relying on the Default Path**:
+
+ In scenarios where neither command-line arguments nor environment variables are provided, OpenIM will intuitively revert to the `config/` directory to locate its configuration.
+
## 1. OpenIM Deployment Guide
diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go
index 3db3ae089..6f3d27b9c 100644
--- a/pkg/common/config/parse.go
+++ b/pkg/common/config/parse.go
@@ -64,6 +64,7 @@ func GetOptionsByNotification(cfg NotificationConf) msgprocessor.Options {
return opts
}
+
func initConfig(config interface{}, configName, configFolderPath string) error {
configFolderPath = filepath.Join(configFolderPath, configName)
_, err := os.Stat(configFolderPath)
@@ -85,9 +86,15 @@ func initConfig(config interface{}, configName, configFolderPath string) error {
}
func InitConfig(configFolderPath string) error {
- if configFolderPath == "" {
- configFolderPath = DefaultFolderPath
- }
+ if configFolderPath == "" {
+ envConfigPath := os.Getenv("OPENIMCONFIG")
+ if envConfigPath != "" {
+ configFolderPath = envConfigPath
+ } else {
+ configFolderPath = DefaultFolderPath
+ }
+ }
+
if err := initConfig(&Config, FileName, configFolderPath); err != nil {
return err
}
diff --git a/scripts/install-im-server.sh b/scripts/install-im-server.sh
index 92e513b43..26ab35b0d 100755
--- a/scripts/install-im-server.sh
+++ b/scripts/install-im-server.sh
@@ -32,6 +32,14 @@ DOCKER_COMPOSE_COMMAND=
# Check if docker-compose command is available
openim::util::check_docker_and_compose_versions
+if command -v docker compose &> /dev/null
+then
+ openim::log::info "docker compose command is available"
+ DOCKER_COMPOSE_COMMAND="docker compose"
+else
+ DOCKER_COMPOSE_COMMAND="docker-compose"
+fi
+
pushd "${OPENIM_ROOT}"
${DOCKER_COMPOSE_COMMAND} stop
curl https://gitee.com/openimsdk/openim-docker/raw/main/example/full-openim-server-and-chat.yml -o docker-compose.yml && make init && docker compose up -d
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index 3a57d1135..cc2c98544 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -45,7 +45,7 @@ ifeq ($(origin GOBIN), undefined)
endif
# COMMANDS is Specify all files under ${ROOT_DIR}/cmd/ and ${ROOT_DIR}/tools/ except those ending in.md
-COMMANDS ?= $(filter-out %.md, $(wildcard ${ROOT_DIR}/cmd/* ${ROOT_DIR}/tools/* ${ROOT_DIR}/cmd/openim-rpc/*))
+COMMANDS ?= $(filter-out %.md, $(wildcard ${ROOT_DIR}/cmd/* ${ROOT_DIR}/tools/* ${ROOT_DIR}/tools/data-conversion/chat/cmd/* ${ROOT_DIR}/tools/data-conversion/openim/cmd/* ${ROOT_DIR}/cmd/openim-rpc/*))
ifeq (${COMMANDS},)
$(error Could not determine COMMANDS, set ROOT_DIR or run in source dir)
endif
@@ -136,6 +136,7 @@ ifneq ($(shell $(GO) version | grep -q -E '\bgo($(GO_SUPPORTED_VERSIONS))\b' &&
$(error unsupported go version. Please make install one of the following supported version: '$(GO_SUPPORTED_VERSIONS)')
endif
+## go.build.%: Build binaries for a specific platform
.PHONY: go.build.%
go.build.%:
$(eval COMMAND := $(word 2,$(subst ., ,$*)))
@@ -159,6 +160,14 @@ go.build.%:
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
$(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/tools/$(COMMAND)/$(COMMAND).go; \
chmod +x $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT); \
+ elif [ -f $(ROOT_DIR)/tools/data-conversion/openim/cmd/$(COMMAND)/$(COMMAND).go ]; then \
+ CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
+ $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/tools/data-conversion/openim/cmd/$(COMMAND)/$(COMMAND).go; \
+ chmod +x $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT); \
+ elif [ -f $(ROOT_DIR)/tools/data-conversion/chat/cmd/$(COMMAND)/$(COMMAND).go ]; then \
+ CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
+ $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/tools/data-conversion/chat/cmd/$(COMMAND)/$(COMMAND).go; \
+ chmod +x $(BIN_TOOLS_DIR)/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT); \
fi \
fi
diff --git a/tools/data-conversion/README.md b/tools/data-conversion/README.md
new file mode 100644
index 000000000..282fbdc03
--- /dev/null
+++ b/tools/data-conversion/README.md
@@ -0,0 +1,103 @@
+
+在更新你的数据迁移README文档时,考虑到清晰、准确和专业的表述是非常重要的。这不仅可以帮助读者更好地理解迁移过程,还可以确保在迁移过程中减少可能出现的错误。以下是对你提供的README文档的一些改进和完善建议:
+
+------
+
+# OpenIM V2 至 V3 数据迁移指南
+
+该指南提供了从 OpenIM V2 迁移至 V3 的详细步骤。请确保在开始迁移过程之前,熟悉所有步骤,并按照指南准确执行。
+
++ [OpenIM Chat](https://github.com/OpenIMSDK/chat)
++ [OpenIM Server](https://github.com/OpenIMSDK/Open-IM-Server)
+
+
+
+### 1. 数据备份
+
+在开始数据迁移之前,强烈建议备份所有相关的数据以防止任何可能的数据丢失。
+
+### 2. 迁移 OpenIM MySQL 数据
+
++ 位置: `open-im-server/v3/tools/data-conversion/openim/mysql.go`
++ 配置 `mysql.go` 文件中的数据库信息。
++ 手动创建 V3 版本的数据库,并确保字符集为 `utf8mb4`。
+
+```bash
+// V2 数据库配置
+var (
+ usernameV2 = "root"
+ passwordV2 = "openIM"
+ addrV2 = "127.0.0.1:13306"
+ databaseV2 = "openIM_v2"
+)
+
+// V3 数据库配置
+var (
+ usernameV3 = "root"
+ passwordV3 = "openIM123"
+ addrV3 = "127.0.0.1:13306"
+ databaseV3 = "openIM_v3"
+)
+```
+
+**执行数据迁移命令:**
+
+```bash
+make build BINS="conversion-mysql"
+```
+
+启动的二进制在 `_output/bin/tools` 中
+
+
+### 3. 转换聊天消息(可选)
+
++ 只支持转换存储在 Kafka 中的消息。
++ 位置: `open-im-server/v3/tools/data-conversion/openim/msg.go`
++ 配置 `msg.go` 文件中的消息和服务器信息。
+
+```bash
+var (
+ topic = "ws2ms_chat" // V2 版本 Kafka 主题
+ kafkaAddr = "127.0.0.1:9092" // V2 版本 Kafka 地址
+ rpcAddr = "127.0.0.1:10130" // V3 版本 RPC 地址
+ adminUserID = "openIM123456" // V3 版本管理员用户ID
+ concurrency = 4 // 并发数量
+)
+```
+
+**执行数据迁移命令:**
+
+```bash
+make build BINS="conversion-msg"
+```
+
+### 4. 转换业务服务器数据
+
++ 只支持转换存储在 Kafka 中的消息。
++ 位置: `open-im-server/v3/tools/data-conversion/chat/chat.go`
++ 需要手动创建 V3 版本的数据库,并确保字符集为 `utf8mb4`。
++ 配置 `main.go` 文件中的数据库信息。
+
+```bash
+// V2 数据库配置
+var (
+ usernameV2 = "root"
+ passwordV2 = "openIM"
+ addrV2 = "127.0.0.1:13306"
+ databaseV2 = "admin_chat"
+)
+
+// V3 数据库配置
+var (
+ usernameV3 = "root"
+ passwordV3 = "openIM123"
+ addrV3 = "127.0.0.1:13306"
+ databaseV3 = "openim_enterprise"
+)
+```
+
+**执行数据迁移命令:**
+
+```bash
+make build BINS="conversion-chat"
+```
\ No newline at end of file
diff --git a/tools/data-conversion/chat/chat.go b/tools/data-conversion/chat/cmd/conversion-chat/chat.go
similarity index 100%
rename from tools/data-conversion/chat/chat.go
rename to tools/data-conversion/chat/cmd/conversion-chat/chat.go
diff --git a/tools/data-conversion/info.md b/tools/data-conversion/info.md
deleted file mode 100644
index 600b1d09c..000000000
--- a/tools/data-conversion/info.md
+++ /dev/null
@@ -1,68 +0,0 @@
-# v2数据迁移工具
-
-### 转换前请做好数据备份!!!
-
-### 转换OPENIM MYSQL数据
- - open-im-server/v3/tools/data-conversion/openim/mysql.go
- - 配置mysql.go数据库信息
- - 需要手动创建v3版本数据库,字符集`utf8mb4`
-
-```go
-var (
- usernameV2 = "root" // v2版本mysql用户名
- passwordV2 = "openIM" // v2版本mysql密码
- addrV2 = "127.0.0.1:13306" // v2版本mysql地址
- databaseV2 = "openIM_v2" // v2版本mysql数据库名字
-)
-
-var (
- usernameV3 = "root" // v3版本mysql用户名
- passwordV3 = "openIM123" // v3版本mysql密码
- addrV3 = "127.0.0.1:13306" // v3版本mysql地址
- databaseV3 = "openIM_v3" // v3版本mysql数据库名字
-)
-```
-```shell
-go run mysql.go
-```
-
-### 转换聊天消息(可选)
-- 目前只支持转换kafka中的消息
-- open-im-server/v3/tools/data-conversion/openim/msg.go
-- 配置msg.go数据库信息
-```go
-var (
- topic = "ws2ms_chat" // v2版本配置文件kafka.topic.ws2ms_chat
- kafkaAddr = "127.0.0.1:9092" // v2版本配置文件kafka.topic.addr
- rpcAddr = "127.0.0.1:10130" // v3版本配置文件rpcPort.openImMessagePort
- adminUserID = "openIM123456" // v3版本管理员userID
- concurrency = 4 // 并发数量
-)
-```
-```shell
-go run msg.go
-```
-
-### 转换业务服务器数据(使用官方业务服务器需要转换)
-- 目前只支持转换kafka中的消息
-- open-im-server/v3/tools/data-conversion/chat/chat.go
-- 需要手动创建v3版本数据库,字符集`utf8mb4`
-- main.go数据库信息
-```go
-var (
- usernameV2 = "root" // v2版本mysql用户名
- passwordV2 = "openIM" // v2版本mysql密码
- addrV2 = "127.0.0.1:13306" // v2版本mysql地址
- databaseV2 = "admin_chat" // v2版本mysql数据库名字
-)
-
-var (
- usernameV3 = "root" // v3版本mysql用户名
- passwordV3 = "openIM123" // v3版本mysql密码
- addrV3 = "127.0.0.1:13306" // v3版本mysql地址
- databaseV3 = "openim_enterprise" // v3版本mysql数据库名字
-)
-```
-```shell
-go run chat.go
-```
\ No newline at end of file
diff --git a/tools/data-conversion/openim/msg.go b/tools/data-conversion/openim/cmd/conversion-msg/conversion-msg.go
similarity index 100%
rename from tools/data-conversion/openim/msg.go
rename to tools/data-conversion/openim/cmd/conversion-msg/conversion-msg.go
diff --git a/tools/data-conversion/openim/mysql.go b/tools/data-conversion/openim/cmd/conversion-mysql/conversion-mysql.go
similarity index 100%
rename from tools/data-conversion/openim/mysql.go
rename to tools/data-conversion/openim/cmd/conversion-mysql/conversion-mysql.go