Skip to content

Commit

Permalink
feat: add openim chat env and config (#306)
Browse files Browse the repository at this point in the history
* feat: add openim chat env and config

Signed-off-by: Xinwei Xiong (cubxxw) <[email protected]>

* fix: remove openim chat config file

Signed-off-by: Xinwei Xiong (cubxxw) <[email protected]>

---------

Signed-off-by: Xinwei Xiong (cubxxw) <[email protected]>
  • Loading branch information
cubxxw authored Dec 15, 2023
1 parent 9284101 commit 4f4de63
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 80 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,5 @@ dist
.todo.md
.note.md

# config files, may contain sensitive informatio
# config files, may contain sensitive informatio
config/config.yaml
3 changes: 2 additions & 1 deletion cmd/api/admin-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ package main

import (
"fmt"
"github.com/OpenIMSDK/chat/pkg/discovery_register"
"math/rand"
"net"
"strconv"
"time"

"github.com/OpenIMSDK/chat/pkg/discovery_register"

"github.com/OpenIMSDK/chat/tools/component"
"github.com/OpenIMSDK/tools/discoveryregistry"

Expand Down
150 changes: 74 additions & 76 deletions config/config.yaml.template
Original file line number Diff line number Diff line change
@@ -1,100 +1,97 @@
# Copyright © 2023 OpenIM open source community. 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.

# 需要先启动OpenIMServer
# OpenIM Server should be started before this configuration is applied
envs:
discovery: "zookeeper"
discovery: "zookeeper" # ENVS_DISCOVERY, e.g., zookeeper, etcd...

# Zookeeper configuration - used for service discovery and coordination
zookeeper:
schema: openim
schema: openim # ZOOKEEPER_SCHEMA, the schema to use in Zookeeper
zkAddr:
- 127.0.0.1:12181
username: ""
password: ""
- 127.0.0.1:12181 # ZOOKEEPER_ADDRESS and ZOOKEEPER_PORT, Zookeeper address and port
username: "" # ZOOKEEPER_USERNAME, Username for Zookeeper authentication
password: "" # ZOOKEEPER_PASSWORD, Password for Zookeeper authentication

# Configuration for the chat API service
chatApi:
openImChatApiPort: [ 10008 ]
listenIP:
openImChatApiPort: [ 10008 ] # OPENIM_CHAT_API_PORT, Port for OpenIM Chat API
listenIP: # CHAT_API_LISTEN_IP, IP address to listen on for Chat API

# Configuration for the admin API service
adminApi:
openImAdminApiPort: [ 10009 ]
listenIP:
openImAdminApiPort: [ 10009 ] # OPENIM_ADMIN_API_PORT, Port for OpenIM Admin API
listenIP: # ADMIN_API_LISTEN_IP, IP address to listen on for Admin API

# RPC configuration for service communication
rpc:
registerIP: #作为rpc启动时,注册到zookeeper的IP,api/gateway能访问到此ip和对应的rpcPort中的端口
listenIP: #默认为0.0.0.0
registerIP: # RPC_REGISTER_IP, IP address to register with Zookeeper for RPC
listenIP: # RPC_LISTEN_IP, IP address to listen on for RPC (default 0.0.0.0)

# Ports for RPC services
rpcPort:
openImAdminPort: [ 30200 ]
openImChatPort: [ 30300 ]
openImAdminPort: [ 30200 ] # OPENIM_ADMIN_PORT, Port for OpenIM Admin RPC service
openImChatPort: [ 30300 ] # OPENIM_CHAT_PORT, Port for OpenIM Chat RPC service

# Names for RPC services registration
rpcRegisterName:
openImAdminName: admin
openImChatName: chat
openImAdminName: admin # Name for OpenIM Admin RPC service
openImChatName: chat # Name for OpenIM Chat RPC service

# 没有配置表示和OpenIM一致
# MySQL database configuration - used for storing OpenIM data
mysql:
address: [ 127.0.0.1:13306 ] #目前仅支持单机
username: root #用户名
password: openIM123 #密码
database: openIM_v3 #不建议修改
maxOpenConn: 1000 #最大连接数
maxIdleConn: 100 #最大空闲连接数
maxLifeTime: 60 #连接可以重复使用的最长时间(秒)
logLevel: 4 #日志级别 1=slient 2=error 3=warn 4=info
slowThreshold: 500 #慢语句阈值 (毫秒)

# 没有配置表示和OpenIM一致
address: [ 127.0.0.1:13306 ] # MYSQL_ADDRESS and MYSQL_PORT, MySQL server address and port
username: root # MYSQL_USERNAME, Username for MySQL
password: openIM123 # MYSQL_PASSWORD, Password for MySQL
database: openIM_v3 # MYSQL_DATABASE, Database name
maxOpenConn: 1000 # Max open connections
maxIdleConn: 100 # Max idle connections
maxLifeTime: 60 # Max lifetime of connections in seconds
logLevel: 4 # Log level for MySQL
slowThreshold: 500 # Slow query threshold in milliseconds

# Log configuration - defines how logging is handled
log:
storageLocation: ../logs/ #存放目录
# rotationTime: 24 #日志旋转时间
# remainRotationCount: 2 #日志数量
# remainLogLevel: 6 #日志级别 6表示全都打印,
# isStdout: false
# isJson: false
# withStack: false

# secret: openIM123
#tokenPolicy:
# expire: 86400

storageLocation: ../logs/ # LOG_STORAGE_LOCATION, Directory for storing logs
rotationTime: 24 # Log rotation time in hours
remainRotationCount: 2 # Number of log files to retain
remainLogLevel: 6 # Log level (6 = all levels)
isStdout: false # Whether to output logs to stdout
isJson: false # Whether to output logs in JSON format
withStack: false # Whether to include stack trace in logs

# Secret key for secure communication
secret: openIM123 # SECRET, Secret key for encryption and secure communication

# Token policy configuration
tokenPolicy:
expire: 86400 # TOKEN_EXPIRE, Token expiration time in seconds

# Verification code settings
verifyCode:
validTime: 300 # 验证码有效时间
validCount: 5 # 验证码有效次数
uintTime: 86400 # 单位时间间隔
maxCount: 10 # 单位时间内最大获取次数
superCode: "666666" # 超级验证码(只有use为空时使用)
len: 6 # 验证码长度
use: "" # 使用的验证码服务(use: "ali")
validTime: 300 # Verification code valid time in seconds
validCount: 5 # Number of times a verification code is valid
uintTime: 86400 # Time unit for verification code
maxCount: 10 # Maximum number of verification codes in a time unit
superCode: "666666" # Super verification code (used only when `use` is empty)
len: 6 # Length of the verification code
use: "" # Service used for verification code (e.g., "ali")
# Aliyun SMS service configuration
ali:
endpoint: "dysmsapi.aliyuncs.com"
accessKeyId: ""
accessKeySecret: ""
signName: ""
verificationCodeTemplateCode: ""
mail: # 根据对应的发件邮箱更改 sendMail、senderAuthorizationCode、smtpAddr、smtpPort 即可
# Email service configuration
mail:
title: ""
senderMail: "" # 发送者
senderAuthorizationCode: "" # 授权码
smtpAddr: "smtp.qq.com" # smtp 服务器地址
smtpPort: 465 # smtp 服务器邮件发送端口
testDepartMentID: 001
imAPIURL: http://127.0.0.1:10002

senderMail: "" # Email address of the sender
senderAuthorizationCode: "" # Authorization code for the sender's email
smtpAddr: "smtp.qq.com" # SMTP server address
smtpPort: 465 # SMTP server port for email sending

# 获取ip的header,没有配置直接获取远程地址
#proxyHeader: "X-Forwarded-For"
# Proxy header configuration for IP extraction
proxyHeader: "X-Forwarded-For" # PROXY_HEADER, Header used for extracting the client IP address

# List of admin users
adminList:
- adminID: admin1
nickname: chat1
Expand All @@ -106,10 +103,11 @@ adminList:
nickname: chat3
imAdmin: openIMAdmin

# URL for OpenIM server
openIMUrl: "http://127.0.0.1:10002" # OPENIM_SERVER_ADDRESS:API_OPENIM_PORT, URL of the OpenIM server

openIMUrl: "http://127.0.0.1:10002"

# Redis configuration - used for caching and session management
redis:
# address: [ 127.0.0.1:16379 ]
# username:
# password: openIM123
address: [ 127.0.0.1:16379 ] # REDIS_ADDRESS and REDIS_PORT, Redis server address and port
username: # REDIS_USERNAME, Username for Redis authentication
password: openIM123 # REDIS_PASSWORD, Password for Redis
2 changes: 0 additions & 2 deletions pkg/common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ var Config struct {
SmtpAddr string `yaml:"smtpAddr"`
SmtpPort int `yaml:"smtpPort"`
} `yaml:"mail"`
TestDepartMentID string `yaml:"testDepartMentID"`
ImAPIURL string `yaml:"imAPIURL"`
} `yaml:"verifyCode"`
ProxyHeader string `yaml:"proxyHeader"`
AdminList []Admin `yaml:"adminList"`
Expand Down
2 changes: 2 additions & 0 deletions scripts/docker_start_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ service_prometheus_port_names=()

cd "$SCRIPTS_ROOT"

cp ./config/config.yaml.template ./config/config.yaml

# Function to kill a service
kill_service() {
local service_name=$1
Expand Down

0 comments on commit 4f4de63

Please sign in to comment.