Organize configuration files and configuration items, and remove redundant fields.

pull/454/head
skiffer-git 2 years ago
parent ee934d7ce7
commit da27adf6a2

@ -1,93 +1,84 @@
# OpenIM config #OpenIM config
#---------------Infrastructure configuration---------------------# #---------------Infrastructure configuration---------------------#
zookeeper: zookeeper:
schema: openim #默认即可 schema: openim #不建议修改
address: [ 127.0.0.1:2181 ] # address: [ 127.0.0.1:2181 ] #
username: username: #用户名
password: password: #密码
mysql: mysql:
address: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可 address: [ 127.0.0.1:13306 ] #目前仅支持单机
username: root #mysql用户名,建议修改 username: root #用户名
password: openIM123 # mysql密码,建议修改 password: openIM123 #密码
database: openIM_v2 #默认即可 database: openIM_v2 #不建议修改
maxOpenConn: 100 # maxOpenConn: 1000 #最大连接数
maxIdleConn: 10 # maxIdleConn: 100 #最大空闲连接数
maxLifeTime: 5 # maxLifeTime: 60 #连接可以重复使用的最长时间(秒)
logLevel: 4 # 1=slient 2=error 3=warn 4=info logLevel: 4 #日志级别 1=slient 2=error 3=warn 4=info
slowThreshold: 500 # 毫秒 slowThreshold: 500 #慢语句阈值 毫秒
mongo: mongo:
uri: #不为空则直接使用该值 uri: #不为空则直接使用该值
address: [ 127.0.0.1:37017 ] #单机时为mongo地址使用分片集群时为mongos地址 默认即可 address: [ 127.0.0.1:37017 ] #单机时为mongo地址使用分片集群时为mongos地址
timeout: 60
database: openIM #mongo db 默认即可 database: openIM #mongo db 默认即可
source: admin username: root #用户名
username: root #mongo用户名建议先不设置 password: openIM123 #密码
password: openIM123 #mongo密码建议先不设置
maxPoolSize: 100 maxPoolSize: 100
retainChatRecords: 3650 #mongo保存离线消息时间根据需求修改
chatRecordsClearTime: "0 2 * * 3" #每周三凌晨2点清除mongo中的过期消息该配置和linux定时任务一样
redis: redis:
address: [ 127.0.0.1:16379 ] #redis地址 单机时填写一个地址即可使用redis集群时候填写集群中多个节点地址主从地址都可以填写增加容灾能力默认即可 address: [ 127.0.0.1:16379 ] #
username: #only redis version 6.0+ need username username: #only redis version 6.0+ need username
password: openIM123 #redis密码 建议修改 password: openIM123 #密码
kafka: kafka:
username: username: #用户名
password: password: #密码
addr: [ 127.0.0.1:9092 ] #kafka配置默认即可 addr: [ 127.0.0.1:9092 ] #
latestMsgToRedis: latestMsgToRedis:
topic: "latestMsgToRedis" # topic: "latestMsgToRedis" #不建议修改
offlineMsgToMongo: offlineMsgToMongo:
topic: "offlineMsgToMongoMysql" #用于mongo和mysql保存消息 topic: "offlineMsgToMongoMysql" #不建议修改
msgToPush: msgToPush:
topic: "msqToPush" #消息push topic: "msqToPush" #不建议修改
msgToModify: msgToModify:
topic: "msgToModify" #消息push topic: "msgToModify" #不建议修改
consumerGroupID: consumerGroupID: #消费者组,不建议修改
msgToRedis: redis msgToRedis: redis #
msgToMongo: mongo msgToMongo: mongo #
msgToMySql: mysql msgToMySql: mysql #
msgToPush: push msgToPush: push #
msgToModify: modify msgToModify: modify #
#---------------Internal service configuration---------------------#
rpc: rpc:
registerIP: #作为rpc启动时注册到zookeeper的IPapi/gateway能访问到此ip和对应的rpcPort中的端口 registerIP: #作为rpc启动时注册到zookeeper的IPapi/gateway能访问到此ip和对应的rpcPort中的端口
listenIP: #如不设置则为 0.0.0.0 listenIP: #默认为0.0.0.0
api: api:
openImApiPort: [ 10002 ] #api服务端口 openImApiPort: [ 10002 ] #api服务端口
listenIP: listenIP: #默认为0.0.0.0
object: object:
enable: minio enable: minio #使用minio
apiURL: http://127.0.0.1:10002/third/object apiURL: http://127.0.0.1:10002/third/object
minio: minio:
tempBucket: "openim" tempBucket: "openim" #不建议修改
dataBucket: "openim" dataBucket: "openim" #不建议修改
location: us-east-1 location: us-east-1 #不建议修改
endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的 endpoint: http://127.0.0.1:10005 #minio对外服务的ip和端口app要能访问此ip和端口
accessKeyID: root accessKeyID: root #ID
secretAccessKey: openIM123 secretAccessKey: openIM123 #秘钥
isDistributedMod: false #是否分布式多硬盘部署 默认docker-compose中为false如果是多硬盘部署需要修改为true isDistributedMod: false #是否分布式多硬盘部署如果是多硬盘部署需要修改为true
tencent: tencent: #tencent cos
appID: appID:
region: region:
bucket: bucket:
secretID: secretID:
secretKey: secretKey:
ali: # ali oss ali: #ali oss
regionID: regionID:
accessKeyID: accessKeyID:
accessKeySecret: accessKeySecret:
@ -98,16 +89,16 @@ object:
stsDurationSeconds: stsDurationSeconds:
OssRoleArn: OssRoleArn:
aws: aws:
accessKeyID: #AssumeRole用户关联的accessKeyID accessKeyID:
accessKeySecret: #AssumeRole用户关联的accessKeySecrect accessKeySecret:
region: #分区 region:
bucket: #桶 bucket:
finalHost: #对外Host finalHost:
roleArn: #RoleArn roleArn:
externalId: #角色扩展Id externalId:
roleSessionName: #角色SESSION名称 roleSessionName:
rpcPort: #rpc服务端口 默认即可 rpcPort: #rpc服务端口不建议修改端口由脚本读取后传入程序如启动多个程序只需要填入多个端口用逗号隔开如 openImUserPort: [10110, 10111]
openImUserPort: [ 10110 ] openImUserPort: [ 10110 ]
openImFriendPort: [ 10120 ] openImFriendPort: [ 10120 ]
openImMessagePort: [ 10130 ] openImMessagePort: [ 10130 ]
@ -119,7 +110,7 @@ rpcPort: #rpc服务端口 默认即可
openImRtcPort: [ 10190 ] openImRtcPort: [ 10190 ]
openImThirdPort: [ 10200 ] openImThirdPort: [ 10200 ]
rpcRegisterName: #rpc注册服务名默认即可 rpcRegisterName: #rpc注册服务名不建议修改
openImUserName: User openImUserName: User
openImFriendName: Friend openImFriendName: Friend
openImMsgName: Msg openImMsgName: Msg
@ -128,71 +119,66 @@ rpcRegisterName: #rpc注册服务名默认即可
openImGroupName: Group openImGroupName: Group
openImAuthName: Auth openImAuthName: Auth
openImConversationName: Conversation openImConversationName: Conversation
openImRtcName: Rtc
openImThirdName: Third openImThirdName: Third
log: log:
storageLocation: ../logs/ storageLocation: ../logs/ #存放目录
rotationTime: 24 rotationTime: 24 #日志旋转时间
remainRotationCount: 2 #日志数量 remainRotationCount: 2 #日志数量
remainLogLevel: 6 #日志级别 6表示全都打印测试阶段建议设置为6 remainLogLevel: 6 #日志级别 6表示全都打印
isStdout: false isStdout: false
isJson: false isJson: false
withStack: false withStack: false
longConnSvr: longConnSvr:
openImWsPort: [ 10001 ] #ws服务端口默认即可要开放此端口或做nginx转发 openImWsPort: [ 10001 ] #msg_gateway的websocket端口
websocketMaxConnNum: 10000 websocketMaxConnNum: 100000 #websocket最大连接数
websocketMaxMsgLen: 4096 websocketMaxMsgLen: 4096 #websocket请求包最大长度
websocketTimeOut: 10 websocketTimeout: 10 #websocket连接握手超时时间
push: push:
enable: getui enable: getui
geTui: #个推推送 geTui: #个推离线推送
pushUrl: "https://restapi.getui.com/v2/$appId" pushUrl: "https://restapi.getui.com/v2/$appId"
masterSecret: "" masterSecret: ""
appKey: "" appKey: ""
intent: "" intent: ""
channelID: "" channelID: ""
channelName: "" channelName: ""
fcm: #firebase cloud message 消息推送 fcm: #fcm离线推送
serviceAccount: "openim-5c6c0-firebase-adminsdk-ppwol-8765884a78.json" #帐号文件,此处需要改修配置,并且这个文件放在 config目录下 serviceAccount: "x.json" #帐号文件,并放在 config目录下
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改 jpns: #极光推送 在极光后台申请后,修改以下四项
appKey: appKey:
masterSecret: masterSecret:
pushUrl: pushUrl:
pushIntent: pushIntent:
enable: false
manager: manager:
#app管理员userID和nickename 用于管理后台登录 userID: [ "openIM123456","openIM654321","openIMAdmin" ] #内置的app管理员userID
userID: [ "openIM123456","openIM654321","openIMAdmin" ] nickname: [ "system1","system2", "system3" ] #内置的app管理员nickname
nickname: [ "system1","system2", "system3" ]
multiLoginPolicy: 1 #多平台登录Android、iOS、Windows、Mac、web 每种平台只能有一个在线
chatPersistenceMysql: true #消息是否存入mysqlmysql中的消息仅用于管理后台使用
msgCacheTimeout: 86400 #信消息缓存时间秒,不建议修改
groupMessageHasReadReceiptEnable: true #群聊已读是否开启
singleMessageHasReadReceiptEnable: true #单聊已读是否开启
retainChatRecords: 365 #mongo保存离线消息时间
chatRecordsClearTime: "0 2 * * 3" #每周三凌晨2点清理mongo中的过期超过retainChatRecords时间消息
# 多端互踢策略
# 1多平台登录Android、iOS、Windows、Mac 每种平台只能一个在线web端可以多个同时在线
multiLoginPolicy: 1
#msg log insert to db
chatPersistenceMysql: true
#消息缓存时间
msgCacheTimeout: 86400
#群聊已读开启
groupMessageHasReadReceiptEnable: true
#单聊已读开启
singleMessageHasReadReceiptEnable: true
#token config
tokenPolicy: tokenPolicy:
accessSecret: openIM123 #token生成相关默认即可 accessSecret: openIM123 #秘钥获取token时校验
# Token effective time day as a unit accessExpire: 90 #过期时间(天)
accessExpire: 90 #token过期时间 默认即可
messageVerify: messageVerify:
friendVerify: false friendVerify: false #发送消息时是否验证好友关系
#ios系统推送声音以及标记计数 #ios系统推送声音以及标记计数
iosPush: iosPush:
@ -201,12 +187,12 @@ iosPush:
production: false production: false
callback: callback:
# callback url 需要自行更换callback url # 回调callback
url: url:
beforeSendSingleMsg: beforeSendSingleMsg:
enable: false # 回调是否启用 enable: false #是否启用此回调事件
timeout: 5 #callback超时时间(秒) timeout: 5 #超时时间(秒)
failedContinue: true #如果callback失败是否继续 failedContinue: true #如回调失败是否继续往后执行
afterSendSingleMsg: afterSendSingleMsg:
enable: false enable: false
timeout: 5 timeout: 5
@ -263,8 +249,8 @@ callback:
timeout: 5 timeout: 5
failedContinue: true failedContinue: true
# prometheus每个服务监听的端口数量需要和rpc port保持一致
prometheus: prometheus: #prometheus每个服务的端口数量需要和rpcPort保持对应
enable: false enable: false
userPrometheusPort: [ 20110 ] userPrometheusPort: [ 20110 ]
friendPrometheusPort: [ 20120 ] friendPrometheusPort: [ 20120 ]
@ -276,5 +262,5 @@ prometheus:
conversationPrometheusPort: [ 20230 ] conversationPrometheusPort: [ 20230 ]
rtcPrometheusPort: [ 21300 ] rtcPrometheusPort: [ 21300 ]
thirdPrometheusPort: [ 21301 ] thirdPrometheusPort: [ 21301 ]
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # 端口数量和 script/path_info.cfg msg_transfer_service_num保持一致 messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] #端口数量需要和script/path_info.cfg中的msg_transfer_service_num保持一致

@ -12,7 +12,7 @@ func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
longServer, err := NewWsServer( longServer, err := NewWsServer(
WithPort(wsPort), WithPort(wsPort),
WithMaxConnNum(int64(config.Config.LongConnSvr.WebsocketMaxConnNum)), WithMaxConnNum(int64(config.Config.LongConnSvr.WebsocketMaxConnNum)),
WithHandshakeTimeout(time.Duration(config.Config.LongConnSvr.WebsocketTimeOut)*time.Second), WithHandshakeTimeout(time.Duration(config.Config.LongConnSvr.WebsocketTimeout)*time.Second),
WithMessageMaxMsgLength(config.Config.LongConnSvr.WebsocketMaxMsgLen)) WithMessageMaxMsgLength(config.Config.LongConnSvr.WebsocketMaxMsgLen))
if err != nil { if err != nil {
return err return err

@ -11,8 +11,8 @@ import (
) )
func StartCronTask() error { func StartCronTask() error {
log.ZInfo(context.Background(), "start cron task", "cron config", config.Config.Mongo.ChatRecordsClearTime) log.ZInfo(context.Background(), "start cron task", "cron config", config.Config.ChatRecordsClearTime)
fmt.Println("cron task start, config", config.Config.Mongo.ChatRecordsClearTime) fmt.Println("cron task start, config", config.Config.ChatRecordsClearTime)
msgTool, err := InitMsgTool() msgTool, err := InitMsgTool()
if err != nil { if err != nil {
return err return err
@ -20,9 +20,9 @@ func StartCronTask() error {
c := cron.New() c := cron.New()
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
_, err = c.AddFunc(config.Config.Mongo.ChatRecordsClearTime, msgTool.AllConversationClearMsgAndFixSeq) _, err = c.AddFunc(config.Config.ChatRecordsClearTime, msgTool.AllConversationClearMsgAndFixSeq)
if err != nil { if err != nil {
fmt.Println("start cron failed", err.Error(), config.Config.Mongo.ChatRecordsClearTime) fmt.Println("start cron failed", err.Error(), config.Config.ChatRecordsClearTime)
return err return err
} }
c.Start() c.Start()

@ -74,8 +74,8 @@ func (c *MsgTool) AllConversationClearMsgAndFixSeq() {
func (c *MsgTool) ClearConversationsMsg(ctx context.Context, conversationIDs []string) { func (c *MsgTool) ClearConversationsMsg(ctx context.Context, conversationIDs []string) {
for _, conversationID := range conversationIDs { for _, conversationID := range conversationIDs {
if err := c.msgDatabase.DeleteConversationMsgsAndSetMinSeq(ctx, conversationID, int64(config.Config.Mongo.RetainChatRecords*24*60*60)); err != nil { if err := c.msgDatabase.DeleteConversationMsgsAndSetMinSeq(ctx, conversationID, int64(config.Config.RetainChatRecords*24*60*60)); err != nil {
log.ZError(ctx, "DeleteUserSuperGroupMsgsAndSetMinSeq failed", err, "conversationID", conversationID, "DBRetainChatRecords", config.Config.Mongo.RetainChatRecords) log.ZError(ctx, "DeleteUserSuperGroupMsgsAndSetMinSeq failed", err, "conversationID", conversationID, "DBRetainChatRecords", config.Config.RetainChatRecords)
} }
if err := c.checkMaxSeq(ctx, conversationID); err != nil { if err := c.checkMaxSeq(ctx, conversationID); err != nil {
log.ZError(ctx, "fixSeq failed", err, "conversationID", conversationID) log.ZError(ctx, "fixSeq failed", err, "conversationID", conversationID)

@ -55,14 +55,10 @@ type config struct {
Mongo struct { Mongo struct {
Uri string `yaml:"uri"` Uri string `yaml:"uri"`
Address []string `yaml:"address"` Address []string `yaml:"address"`
Timeout int `yaml:"timeout"`
Database string `yaml:"database"` Database string `yaml:"database"`
Source string `yaml:"source"`
Username string `yaml:"username"` Username string `yaml:"username"`
Password string `yaml:"password"` Password string `yaml:"password"`
MaxPoolSize int `yaml:"maxPoolSize"` MaxPoolSize int `yaml:"maxPoolSize"`
RetainChatRecords int `yaml:"retainChatRecords"`
ChatRecordsClearTime string `yaml:"chatRecordsClearTime"`
} `yaml:"mongo"` } `yaml:"mongo"`
Redis struct { Redis struct {
@ -170,7 +166,6 @@ type config struct {
OpenImGroupName string `yaml:"openImGroupName"` OpenImGroupName string `yaml:"openImGroupName"`
OpenImAuthName string `yaml:"openImAuthName"` OpenImAuthName string `yaml:"openImAuthName"`
OpenImConversationName string `yaml:"openImConversationName"` OpenImConversationName string `yaml:"openImConversationName"`
OpenImRtcName string `yaml:"openImRtcName"`
OpenImThirdName string `yaml:"openImThirdName"` OpenImThirdName string `yaml:"openImThirdName"`
} `yaml:"rpcRegisterName"` } `yaml:"rpcRegisterName"`
@ -188,7 +183,7 @@ type config struct {
OpenImWsPort []int `yaml:"openImWsPort"` OpenImWsPort []int `yaml:"openImWsPort"`
WebsocketMaxConnNum int `yaml:"websocketMaxConnNum"` WebsocketMaxConnNum int `yaml:"websocketMaxConnNum"`
WebsocketMaxMsgLen int `yaml:"websocketMaxMsgLen"` WebsocketMaxMsgLen int `yaml:"websocketMaxMsgLen"`
WebsocketTimeOut int `yaml:"websocketTimeOut"` WebsocketTimeout int `yaml:"websocketTimeout"`
} `yaml:"longConnSvr"` } `yaml:"longConnSvr"`
Push struct { Push struct {
@ -221,7 +216,8 @@ type config struct {
MsgCacheTimeout int `yaml:"msgCacheTimeout"` MsgCacheTimeout int `yaml:"msgCacheTimeout"`
GroupMessageHasReadReceiptEnable bool `yaml:"groupMessageHasReadReceiptEnable"` GroupMessageHasReadReceiptEnable bool `yaml:"groupMessageHasReadReceiptEnable"`
SingleMessageHasReadReceiptEnable bool `yaml:"singleMessageHasReadReceiptEnable"` SingleMessageHasReadReceiptEnable bool `yaml:"singleMessageHasReadReceiptEnable"`
RetainChatRecords int `yaml:"retainChatRecords"`
ChatRecordsClearTime string `yaml:"chatRecordsClearTime"`
TokenPolicy struct { TokenPolicy struct {
AccessSecret string `yaml:"accessSecret"` AccessSecret string `yaml:"accessSecret"`
AccessExpire int64 `yaml:"accessExpire"` AccessExpire int64 `yaml:"accessExpire"`

@ -18,15 +18,15 @@ import (
) )
func Test_BatchInsertChat2DB(t *testing.T) { func Test_BatchInsertChat2DB(t *testing.T) {
config.Config.Mongo.DBAddress = []string{"192.168.44.128:37017"} config.Config.Mongo.Address = []string{"192.168.44.128:37017"}
config.Config.Mongo.DBTimeout = 60 config.Config.Mongo.Timeout = 60
config.Config.Mongo.DBDatabase = "openIM" config.Config.Mongo.Database = "openIM"
config.Config.Mongo.DBSource = "admin" config.Config.Mongo.Source = "admin"
config.Config.Mongo.DBUserName = "root" config.Config.Mongo.Username = "root"
config.Config.Mongo.DBPassword = "openIM123" config.Config.Mongo.Password = "openIM123"
config.Config.Mongo.DBMaxPoolSize = 100 config.Config.Mongo.MaxPoolSize = 100
config.Config.Mongo.DBRetainChatRecords = 3650 config.Config.RetainChatRecords = 3650
config.Config.Mongo.ChatRecordsClearTime = "0 2 * * 3" config.Config.ChatRecordsClearTime = "0 2 * * 3"
mongo, err := unrelation.NewMongo() mongo, err := unrelation.NewMongo()
if err != nil { if err != nil {
@ -129,15 +129,15 @@ func Test_BatchInsertChat2DB(t *testing.T) {
} }
func GetDB() *commonMsgDatabase { func GetDB() *commonMsgDatabase {
config.Config.Mongo.DBAddress = []string{"192.168.44.128:37017"} config.Config.Mongo.Address = []string{"192.168.44.128:37017"}
config.Config.Mongo.DBTimeout = 60 config.Config.Mongo.Timeout = 60
config.Config.Mongo.DBDatabase = "openIM" config.Config.Mongo.Database = "openIM"
config.Config.Mongo.DBSource = "admin" config.Config.Mongo.Source = "admin"
config.Config.Mongo.DBUserName = "root" config.Config.Mongo.Username = "root"
config.Config.Mongo.DBPassword = "openIM123" config.Config.Mongo.Password = "openIM123"
config.Config.Mongo.DBMaxPoolSize = 100 config.Config.Mongo.MaxPoolSize = 100
config.Config.Mongo.DBRetainChatRecords = 3650 config.Config.RetainChatRecords = 3650
config.Config.Mongo.ChatRecordsClearTime = "0 2 * * 3" config.Config.ChatRecordsClearTime = "0 2 * * 3"
mongo, err := unrelation.NewMongo() mongo, err := unrelation.NewMongo()
if err != nil { if err != nil {

Loading…
Cancel
Save