mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
config file update
This commit is contained in:
parent
365d282119
commit
fd256a6c28
@ -23,7 +23,7 @@ mysql:
|
|||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
dbUri: ""#当dbUri值不为空则直接使用该值
|
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||||
dbAddress: [ 127.0.0.1:37017 ] #mongo地址 目前仅支持单机,默认即可
|
dbAddress: 127.0.0.1:37017 #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
||||||
dbDirect: false
|
dbDirect: false
|
||||||
dbTimeout: 60
|
dbTimeout: 60
|
||||||
dbDatabase: openIM #mongo db 默认即可
|
dbDatabase: openIM #mongo db 默认即可
|
||||||
@ -34,12 +34,12 @@ mongo:
|
|||||||
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
dbAddress: 127.0.0.1:16379 #redis地址 目前仅支持单机,默认即可
|
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时,填写一个地址即可,使用redis集群时候,填写集群中多个节点地址(主从地址都可以填写,增加容灾能力),默认即可
|
||||||
dbMaxIdle: 128
|
dbMaxIdle: 128
|
||||||
dbMaxActive: 0
|
dbMaxActive: 0
|
||||||
dbIdleTimeout: 120
|
dbIdleTimeout: 120
|
||||||
dbPassWord: openIM #redis密码 建议修改
|
dbPassWord: openIM #redis密码 建议修改
|
||||||
enableCluster: false
|
enableCluster: false #如果外部redis以集群方式启动,需要打开此开关
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
ws2mschat:
|
ws2mschat:
|
||||||
|
@ -85,24 +85,24 @@ type config struct {
|
|||||||
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
|
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
|
||||||
}
|
}
|
||||||
Mongo struct {
|
Mongo struct {
|
||||||
DBUri string `yaml:"dbUri"`
|
DBUri string `yaml:"dbUri"`
|
||||||
DBAddress []string `yaml:"dbAddress"`
|
DBAddress string `yaml:"dbAddress"`
|
||||||
DBDirect bool `yaml:"dbDirect"`
|
DBDirect bool `yaml:"dbDirect"`
|
||||||
DBTimeout int `yaml:"dbTimeout"`
|
DBTimeout int `yaml:"dbTimeout"`
|
||||||
DBDatabase string `yaml:"dbDatabase"`
|
DBDatabase string `yaml:"dbDatabase"`
|
||||||
DBSource string `yaml:"dbSource"`
|
DBSource string `yaml:"dbSource"`
|
||||||
DBUserName string `yaml:"dbUserName"`
|
DBUserName string `yaml:"dbUserName"`
|
||||||
DBPassword string `yaml:"dbPassword"`
|
DBPassword string `yaml:"dbPassword"`
|
||||||
DBMaxPoolSize int `yaml:"dbMaxPoolSize"`
|
DBMaxPoolSize int `yaml:"dbMaxPoolSize"`
|
||||||
DBRetainChatRecords int `yaml:"dbRetainChatRecords"`
|
DBRetainChatRecords int `yaml:"dbRetainChatRecords"`
|
||||||
}
|
}
|
||||||
Redis struct {
|
Redis struct {
|
||||||
DBAddress string `yaml:"dbAddress"`
|
DBAddress []string `yaml:"dbAddress"`
|
||||||
DBMaxIdle int `yaml:"dbMaxIdle"`
|
DBMaxIdle int `yaml:"dbMaxIdle"`
|
||||||
DBMaxActive int `yaml:"dbMaxActive"`
|
DBMaxActive int `yaml:"dbMaxActive"`
|
||||||
DBIdleTimeout int `yaml:"dbIdleTimeout"`
|
DBIdleTimeout int `yaml:"dbIdleTimeout"`
|
||||||
DBPassWord string `yaml:"dbPassWord"`
|
DBPassWord string `yaml:"dbPassWord"`
|
||||||
EnableCluster bool `yaml:"enableCluster"`
|
EnableCluster bool `yaml:"enableCluster"`
|
||||||
}
|
}
|
||||||
RpcPort struct {
|
RpcPort struct {
|
||||||
OpenImUserPort []int `yaml:"openImUserPort"`
|
OpenImUserPort []int `yaml:"openImUserPort"`
|
||||||
|
@ -56,11 +56,11 @@ func init() {
|
|||||||
uri = config.Config.Mongo.DBUri
|
uri = config.Config.Mongo.DBUri
|
||||||
} else {
|
} else {
|
||||||
if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
|
if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
|
||||||
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress[0],
|
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress,
|
||||||
config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize)
|
config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize)
|
||||||
} else {
|
} else {
|
||||||
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||||
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
config.Config.Mongo.DBAddress, config.Config.Mongo.DBDatabase,
|
||||||
config.Config.Mongo.DBMaxPoolSize)
|
config.Config.Mongo.DBMaxPoolSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ func init() {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
if config.Config.Redis.EnableCluster {
|
if config.Config.Redis.EnableCluster {
|
||||||
DB.rdb = go_redis.NewClusterClient(&go_redis.ClusterOptions{
|
DB.rdb = go_redis.NewClusterClient(&go_redis.ClusterOptions{
|
||||||
Addrs: []string{config.Config.Redis.DBAddress},
|
Addrs: config.Config.Redis.DBAddress,
|
||||||
PoolSize: 50,
|
PoolSize: 50,
|
||||||
})
|
})
|
||||||
_, err = DB.rdb.Ping(ctx).Result()
|
_, err = DB.rdb.Ping(ctx).Result()
|
||||||
@ -132,7 +132,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DB.rdb = go_redis.NewClient(&go_redis.Options{
|
DB.rdb = go_redis.NewClient(&go_redis.Options{
|
||||||
Addr: config.Config.Redis.DBAddress,
|
Addr: config.Config.Redis.DBAddress[0],
|
||||||
Password: config.Config.Redis.DBPassWord, // no password set
|
Password: config.Config.Redis.DBPassWord, // no password set
|
||||||
DB: 0, // use default DB
|
DB: 0, // use default DB
|
||||||
PoolSize: 100, // 连接池大小
|
PoolSize: 100, // 连接池大小
|
||||||
|
@ -17,11 +17,11 @@ func init() {
|
|||||||
uri = config.Config.Mongo.DBUri
|
uri = config.Config.Mongo.DBUri
|
||||||
} else {
|
} else {
|
||||||
if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
|
if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
|
||||||
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress[0],
|
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress,
|
||||||
config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize)
|
config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize)
|
||||||
} else {
|
} else {
|
||||||
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||||
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
config.Config.Mongo.DBAddress, config.Config.Mongo.DBDatabase,
|
||||||
config.Config.Mongo.DBMaxPoolSize)
|
config.Config.Mongo.DBMaxPoolSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user