test-errcode
wangchuxiao 2 years ago
parent 9abff13008
commit 01ccb6f404

@ -1,19 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_api $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -1,56 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment
spec:
selector:
matchLabels:
app: api # 选择这个指定标签执行
replicas: 1 # 运行pod数量
template:
metadata:
labels:
app: api # 标签
spec:
containers:
- name: api
image: openim/api:v2.3.4
# imagePullPolicy: Always
ports:
- containerPort: 10002
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
---
apiVersion: v1
kind: Service
metadata:
name: api
spec:
ports:
- name: api-port
protocol: TCP
port: 10002
targetPort: 10002
selector:
app: api
type: NodePort

@ -1,19 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_auth $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -1,42 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: auth-deployment
spec:
selector:
matchLabels:
app: auth # 选择这个指定标签执行
replicas: 1 # 运行pod数量
template:
metadata:
labels:
app: auth # 标签
spec:
containers:
- name: auth
image: openim/auth:v2.3.4
# imagePullPolicy: Always
ports:
- containerPort: 10160
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新

@ -1,30 +0,0 @@
#/bin/sh
source ./path_info.cfg
# images version
version=v2.3.4
git pull
cd ../script/; ./build_all_service.sh
cd ../deploy_k8s/
for i in ${service[*]}
do
mv ../bin/open_im_${i} ./${i}/
done
echo "move success"
echo "start to build images"
for i in ${service[*]}
do
echo "start to build images" $i
cd $i
image="openim/${i}:$version"
docker build -t $image . -f ./${i}.Dockerfile
echo "build ${dockerfile} success"
docker push $image
echo "push ${image} success "
cd ..
done

@ -1,18 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_conversation $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -1,44 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: conversation-deployment
spec:
selector:
matchLabels:
app: conversation # 选择这个指定标签执行
replicas: 2 # 运行pod数量
template:
metadata:
labels:
app: conversation # 标签
spec:
containers:
- name: conversation
image: openim/conversation:v2.3.4
# imagePullPolicy: Always
ports:
- containerPort: 10230
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新

@ -1,43 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: friend-deployment
spec:
selector:
matchLabels:
app: friend # 选择这个指定标签执行
replicas: 1 # 运行pod数量
template:
metadata:
labels:
app: friend # 标签
spec:
containers:
- name: friend
image: openim/friend:v2.3.4
# imagePullPolicy: Always
ports:
- containerPort: 10120
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新

@ -1,19 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_friend $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -1,42 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: group-deployment
spec:
selector:
matchLabels:
app: group # 选择这个指定标签执行
replicas: 1 # 运行pod数量
template:
metadata:
labels:
app: group # 标签
spec:
containers:
- name: group
image: openim/group:v2.3.4
# imagePullPolicy: Always
ports:
- containerPort: 10150
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新

@ -1,19 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_group $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -1,47 +0,0 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
name: msg-gateway-ingress
spec:
rules:
- host: msg-gateway.openim.xxx.com
http:
paths:
- backend:
service:
name: msg-gateway
port:
number: 10001
path: /
pathType: Prefix
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/Access-Control-Allow-Origin: '*'
nginx.ingress.kubernetes.io/cors-allow-headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-auth-token,Pagination
nginx.ingress.kubernetes.io/cors-allow-methods: 'PUT, GET, POST, OPTIONS'
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
nginx.ingress.kubernetes.io/enable-cors: 'true'
nginx.ingress.kubernetes.io/service-weight: ''
name: api-ingress
spec:
rules:
- host: api.openim.xxx.com
http:
paths:
- backend:
service:
name: api
port:
number: 10002
path: /
pathType: Prefix

@ -1,97 +0,0 @@
# openIM k8s部署文档
### 1. 修改配置文件
在Open-IM-SERVER根目录下修改config/config.yaml配置文件, 请确保以下修改的所有地址必须保证k8s pod能够访问
1. 修改ETCD配置为自己的ETCD ip地址, 最好和k8s本身使用的ETCD分开
2. 修改MySQL配置
3. 修改Mongo配置
4. 修改Redis配置
5. 修改Kafka配置
6. 将rpcRegisterIP修改为空, 此地址为每个rpc注册到ETCD的地址, 置空每个rpc将会将pod地址注册到ETCD, 才能正确rpc请求(重要)
7. 如果使用minio作为对象存储, 还需要修改minio的地址
8. 其他如果使用离线推送,需要修改push离线推送配置
9. 其他非必须配置修改, 如短信,推送等
### 2. 项目根目录创建im configMap到k8s openim namespace
1. 为open-IM项目创建单独命名空间
```
kubectl create namespace openim
```
2. 在项目根目录通过config/config.yaml
```
kubectl -n openim create configmap config --from-file=config/config.yaml
kubectl -n openim create configmap usualConfig --from-file=config/usualConfig.yaml
```
查看configmap
```
kubectl -n openim get configmap
```
### 3(可选). 修改每个deployment.yml
每个rpc的deployment在Open-IM-SERVER根目录deploy_k8s下
给需要调度的node打上标签
```
kubectl get nodes
kubectl label node k8s-node1 role=openIMworker
```
在deployment的spec.template.spec加上
```
nodeSelector:
role: openIMworker
```
创建资源清单时添加上nodeSelector属性对应即可,
修改每种服务数量建议至少每种2个rpc。
如果修改了config/config.yaml某些配置比如端口同时需要修改对应deployment端口和ingress端口
### 4. 修改ingress.yaml配置文件
1. 需要安装ingress controller, 这里使用的是ingress-nginx, 使用其他类型的ingress controller需要更改ingress.class, 将host改为自己部署服务的host
### 5. 执行./kubectl_start.sh脚本
1. 脚本给予可执行权限
```
chmod +x ./kubectl_start.sh ./kubectl_stop.sh
```
2. 启动k8s service和deployment
```
./kubectl_start.sh
```
3. 启动k8s ingress
```
kubectl -n openim apply -f ingress.yaml
```
kubectl 启动所有deployment, services, ingress
### 6. 查看k8s deployment service ingress状态
```
kubectl -n openim get services
kubectl -n openim get deployment
kubectl -n openim get ingress
kubectl -n openim get pods
```
检测服务可达
```
telnet msg-gateway.openim.xxx.com {{your_ingress_port}}
telnet sdk-server.openim.xxx.com {{your_ingress_port}}
telnet api.openim.xxx.com {{your_ingress_port}}
```
#### openIM k8s更新
1. 暂存配置文件,拉取代码
```
git stash push config/config.yaml
git pull
```
2. 合并配置文件, 解决冲突
```
git stash pop
```
3. 重新生成configmap
```
kubectl -n openim create configmap config --from-file=config/config.yaml
```
4.修改所有deployment文件的spec.template.spec.image 改为新版本后在/deploy_k8s下重新执行
```
./kubectl_stop.sh
./kubectl_start.sh
```

@ -1,11 +0,0 @@
#!/usr/bin/env bash
source ./path_info.cfg
#mkdir -p /db/sdk #path for jssdk sqlite
for i in ${service[*]}
do
kubectl -n openim apply -f ./${i}/deployment.yaml
done

@ -1,26 +0,0 @@
#!/usr/bin/env bash
service=(
#api service file
api
#rpc service file
user
friend
group
auth
conversation
msg-gateway
msg-transfer
msg
push
)
for i in ${service[*]}
do
kubectl -n openim delete deployment "${i}-deployment"
done
kubectl -n openim delete service api
kubectl -n openim delete service msg-gateway
echo done

@ -1,42 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: msg-deployment
spec:
selector:
matchLabels:
app: msg # 选择这个指定标签执行
replicas: 1 # 运行pod数量
template:
metadata:
labels:
app: msg # 标签
spec:
containers:
- name: msg
image: openim/msg:v2.3.4
# imagePullPolicy: Always
ports:
- containerPort: 10130
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新

@ -1,20 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_msg $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -1,61 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: msg-gateway-deployment
spec:
selector:
matchLabels:
app: msg-gateway # 选择这个指定标签执行
replicas: 1 # 运行pod数量
template:
metadata:
labels:
app: msg-gateway # 标签
spec:
containers:
- name: msg-gateway
image: openim/msg_gateway:v2.3.4
# imagePullPolicy: Always
ports:
- name: rpc-port
containerPort: 10140
- name: ws-port
containerPort: 10001
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
---
apiVersion: v1
kind: Service
metadata:
name: msg-gateway
spec:
ports:
- name: msg-gateway-port
protocol: TCP
port: 10001
targetPort: ws-port
selector:
app: msg-gateway
type: NodePort

@ -1,19 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_msg_gateway $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -1,40 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: msg-transfer-deployment
spec:
selector:
matchLabels:
app: msg-transfer # 选择这个指定标签执行
replicas: 1 # 运行pod数量
template:
metadata:
labels:
app: msg-transfer # 标签
spec:
containers:
- name: msg-transfer
image: openim/msg_transfer:v2.3.4
# imagePullPolicy: Always
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新

@ -1,19 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_msg_transfer $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -1,15 +0,0 @@
#/bin/sh
service=(
#api service file
api
#rpc service file
user
friend
group
auth
conversation
msg_gateway
msg_transfer
msg
push
)

@ -1,42 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: push-deployment
spec:
selector:
matchLabels:
app: push # 选择这个指定标签执行
replicas: 1 # 运行pod数量
template:
metadata:
labels:
app: push # 标签
spec:
containers:
- name: push
image: openim/push:v2.3.4
# imagePullPolicy: Always
ports:
- containerPort: 10170
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新

@ -1,20 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_push $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -1,40 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: user-deployment
spec:
selector:
matchLabels:
app: user # 选择这个指定标签执行
replicas: 1 # 运行pod数量
template:
metadata:
labels:
app: user # 标签
spec:
containers:
- name: user
image: openim/user:v2.3.4
# imagePullPolicy: Always
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
- name: USUAL_CONFIG_NAME
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
strategy: #更新策略
type: RollingUpdate # 滚动更新

@ -1,19 +0,0 @@
FROM ubuntu
# 设置固定的项目路径
ENV WORKDIR /Open-IM-Server
ENV CMDDIR $WORKDIR/cmd
ENV CONFIG_NAME $WORKDIR/config/config.yaml
# 将可执行文件复制到目标目录
ADD ./open_im_user $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
chmod +x $WORKDIR/cmd/main
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
WORKDIR $CMDDIR
CMD ./main

@ -127,7 +127,7 @@ services:
container_name: open_im_enterprise
volumes:
- ./logs:/Open-IM-Enterprise/logs
- ./docker-compose_cfg/config.yaml:/Open-IM-Enterprise/config/config.yaml
- ./.docker-compose_cfg/config.yaml:/Open-IM-Enterprise/config/config.yaml
restart: always
depends_on:
- mysql
@ -147,7 +147,7 @@ services:
prometheus:
image: prom/prometheus
volumes:
- ./docker-compose_cfg/prometheus-compose.yml:/etc/prometheus/prometheus.yml
- ./.docker-compose_cfg/prometheus-compose.yml:/etc/prometheus/prometheus.yml
container_name: prometheus
# ports:
# - 9091:9091
@ -161,9 +161,9 @@ services:
volumes:
# - ./grafana/dashboards/dashboard.json:/var/lib/grafana/dashboards/dashboard.json
# - ./grafana/provisioning/dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
- ./docker-compose_cfg/datasource-compose.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
- ./docker-compose_cfg/grafana.ini:/etc/grafana/grafana.ini
- ./docker-compose_cfg/node-exporter-full_rev1.json:/var/lib/grafana/dashboards/node-exporter-full_rev1.json
- ./.docker-compose_cfg/datasource-compose.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
- ./.docker-compose_cfg/grafana.ini:/etc/grafana/grafana.ini
- ./.docker-compose_cfg/node-exporter-full_rev1.json:/var/lib/grafana/dashboards/node-exporter-full_rev1.json
container_name: grafana
# ports:
# - 10007:10007

@ -49,14 +49,13 @@ edit_config() {
}
edit_enterprise_config() {
echo "Is edit enterprise config.yaml?"
echo "1. vi edit enterprise config"
echo "2. do not edit enterprise config"
read choice
case $choice in
1)
vi docker-compose_cfg/config.yaml
vi ./.docker-compose_cfg/config.yaml
;;
2)
echo "Do not edit enterprise config"

@ -1,119 +0,0 @@
package group
import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
pbGroup "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"time"
)
func DbToPbGroupInfo(m *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo {
return &sdkws.GroupInfo{
GroupID: m.GroupID,
GroupName: m.GroupName,
Notification: m.Notification,
Introduction: m.Introduction,
FaceURL: m.FaceURL,
OwnerUserID: ownerUserID,
CreateTime: m.CreateTime.UnixMilli(),
MemberCount: memberCount,
Ex: m.Ex,
Status: m.Status,
CreatorUserID: m.CreatorUserID,
GroupType: m.GroupType,
NeedVerification: m.NeedVerification,
LookMemberInfo: m.LookMemberInfo,
ApplyMemberFriend: m.ApplyMemberFriend,
NotificationUpdateTime: m.NotificationUpdateTime.UnixMilli(),
NotificationUserID: m.NotificationUserID,
}
}
func PbToDbGroupRequest(req *pbGroup.GroupApplicationResponseReq, handleUserID string) *relation.GroupRequestModel {
return &relation.GroupRequestModel{
UserID: req.FromUserID,
GroupID: req.GroupID,
HandleResult: req.HandleResult,
HandledMsg: req.HandledMsg,
HandleUserID: handleUserID,
HandledTime: time.Now(),
}
}
func DbToPbCMSGroup(m *relation.GroupModel, ownerUserID string, ownerUserName string, memberCount uint32) *pbGroup.CMSGroup {
return &pbGroup.CMSGroup{
GroupInfo: DbToPbGroupInfo(m, ownerUserID, memberCount),
GroupOwnerUserID: ownerUserID,
GroupOwnerUserName: ownerUserName,
}
}
func DbToPbGroupMembersCMSResp(m *relation.GroupMemberModel) *sdkws.GroupMemberFullInfo {
return &sdkws.GroupMemberFullInfo{
GroupID: m.GroupID,
UserID: m.UserID,
RoleLevel: m.RoleLevel,
JoinTime: m.JoinTime.UnixMilli(),
Nickname: m.Nickname,
FaceURL: m.FaceURL,
//AppMangerLevel: m.AppMangerLevel,
JoinSource: m.JoinSource,
OperatorUserID: m.OperatorUserID,
Ex: m.Ex,
MuteEndTime: m.MuteEndTime.UnixMilli(),
InviterUserID: m.InviterUserID,
}
}
func DbToPbGroupRequest(m *relation.GroupRequestModel, user *sdkws.PublicUserInfo, group *sdkws.GroupInfo) *sdkws.GroupRequest {
return &sdkws.GroupRequest{
UserInfo: user,
GroupInfo: group,
HandleResult: m.HandleResult,
ReqMsg: m.ReqMsg,
HandleMsg: m.HandledMsg,
ReqTime: m.ReqTime.UnixMilli(),
HandleUserID: m.HandleUserID,
HandleTime: m.HandledTime.UnixMilli(),
Ex: m.Ex,
JoinSource: m.JoinSource,
InviterUserID: m.InviterUserID,
}
}
func DbToPbGroupAbstractInfo(groupID string, groupMemberNumber uint32, groupMemberListHash uint64) *pbGroup.GroupAbstractInfo {
return &pbGroup.GroupAbstractInfo{
GroupID: groupID,
GroupMemberNumber: groupMemberNumber,
GroupMemberListHash: groupMemberListHash,
}
}
func PbToDBGroupInfo(m *sdkws.GroupInfo) *relation.GroupModel {
return &relation.GroupModel{
GroupID: m.GroupID,
GroupName: m.GroupName,
Notification: m.Notification,
Introduction: m.Introduction,
FaceURL: m.FaceURL,
CreateTime: time.Now(),
Ex: m.Ex,
Status: m.Status,
CreatorUserID: m.CreatorUserID,
GroupType: m.GroupType,
NeedVerification: m.NeedVerification,
LookMemberInfo: m.LookMemberInfo,
ApplyMemberFriend: m.ApplyMemberFriend,
NotificationUpdateTime: time.UnixMilli(m.NotificationUpdateTime),
NotificationUserID: m.NotificationUserID,
}
}
func PbToDbGroupMember(m *sdkws.UserInfo) *relation.GroupMemberModel {
return &relation.GroupMemberModel{
UserID: m.UserID,
Nickname: m.Nickname,
FaceURL: m.FaceURL,
Ex: m.Ex,
}
}

@ -11,6 +11,7 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
@ -151,12 +152,12 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
return nil, err
}
var groupMembers []*relationTb.GroupMemberModel
group := PbToDBGroupInfo(req.GroupInfo)
group := convert.Pb2DBGroupInfo(req.GroupInfo)
if err := s.GenGroupID(ctx, &group.GroupID); err != nil {
return nil, err
}
joinGroup := func(userID string, roleLevel int32) error {
groupMember := PbToDbGroupMember(userMap[userID])
groupMember := convert.Pb2DbGroupMember(userMap[userID])
groupMember.Nickname = ""
groupMember.GroupID = group.GroupID
groupMember.RoleLevel = roleLevel
@ -194,7 +195,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
return nil, err
}
resp := &pbGroup.CreateGroupResp{GroupInfo: &sdkws.GroupInfo{}}
resp.GroupInfo = DbToPbGroupInfo(group, req.OwnerUserID, uint32(len(userIDs)))
resp.GroupInfo = convert.Db2PbGroupInfo(group, req.OwnerUserID, uint32(len(userIDs)))
resp.GroupInfo.MemberCount = uint32(len(userIDs))
if req.GroupInfo.GroupType == constant.SuperGroup {
go func() {
@ -247,7 +248,7 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
resp.Groups = utils.Slice(utils.Order(groupIDs, groups, func(group *relationTb.GroupModel) string {
return group.GroupID
}), func(group *relationTb.GroupModel) *sdkws.GroupInfo {
return DbToPbGroupInfo(group, ownerMap[group.GroupID].UserID, groupMemberNum[group.GroupID])
return convert.Db2PbGroupInfo(group, ownerMap[group.GroupID].UserID, groupMemberNum[group.GroupID])
})
return resp, nil
}
@ -323,7 +324,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
opUserID := mcontext.GetOpUserID(ctx)
var groupMembers []*relationTb.GroupMemberModel
for _, userID := range req.InvitedUserIDs {
member := PbToDbGroupMember(userMap[userID])
member := convert.Pb2DbGroupMember(userMap[userID])
member.Nickname = ""
member.GroupID = req.GroupID
member.RoleLevel = constant.GroupOrdinaryUsers
@ -371,7 +372,7 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
if e.Nickname == "" {
e.Nickname = nameMap[e.UserID]
}
return DbToPbGroupMembersCMSResp(e)
return convert.Db2PbGroupMembersCMSResp(e)
})
return resp, nil
}
@ -394,7 +395,7 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGr
if e.Nickname == "" {
e.Nickname = nameMap[e.UserID]
}
return DbToPbGroupMembersCMSResp(e)
return convert.Db2PbGroupMembersCMSResp(e)
})
return resp, nil
}
@ -491,7 +492,7 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
if e.Nickname == "" {
e.Nickname = nameMap[e.UserID]
}
return DbToPbGroupMembersCMSResp(e)
return convert.Db2PbGroupMembersCMSResp(e)
})
return resp, nil
}
@ -542,7 +543,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
return e.GroupID
})
resp.GroupRequests = utils.Slice(groupRequests, func(e *relationTb.GroupRequestModel) *sdkws.GroupRequest {
return DbToPbGroupRequest(e, userMap[e.UserID], DbToPbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID])))
return convert.Db2PbGroupRequest(e, userMap[e.UserID], convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID])))
})
return resp, nil
}
@ -568,7 +569,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
return e.GroupID
})
resp.GroupInfos = utils.Slice(groups, func(e *relationTb.GroupModel) *sdkws.GroupInfo {
return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, groupMemberNumMap[e.GroupID])
return convert.Db2PbGroupInfo(e, ownerMap[e.GroupID].UserID, groupMemberNumMap[e.GroupID])
})
return resp, nil
}
@ -665,7 +666,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
if group.GroupType == constant.SuperGroup {
return nil, errs.ErrGroupTypeNotSupport.Wrap()
}
groupMember := PbToDbGroupMember(user)
groupMember := convert.Pb2DbGroupMember(user)
groupMember.GroupID = group.GroupID
groupMember.RoleLevel = constant.GroupOrdinaryUsers
groupMember.OperatorUserID = mcontext.GetOpUserID(ctx)
@ -873,7 +874,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
}
resp.Groups = utils.Slice(groups, func(group *relationTb.GroupModel) *pbGroup.CMSGroup {
member := ownerMemberMap[group.GroupID]
return DbToPbCMSGroup(group, member.UserID, member.Nickname, uint32(groupMemberNumMap[group.GroupID]))
return convert.Db2PbCMSGroup(group, member.UserID, member.Nickname, uint32(groupMemberNumMap[group.GroupID]))
})
return resp, nil
}
@ -895,7 +896,7 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGr
if e.Nickname == "" {
e.Nickname = nameMap[e.UserID]
}
return DbToPbGroupMembersCMSResp(e)
return convert.Db2PbGroupMembersCMSResp(e)
})
return resp, nil
}
@ -947,7 +948,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
return nil, err
}
resp.GroupRequests = utils.Slice(requests, func(e *relationTb.GroupRequestModel) *sdkws.GroupRequest {
return DbToPbGroupRequest(e, user, DbToPbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])))
return convert.Db2PbGroupRequest(e, user, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])))
})
return resp, nil
}
@ -1176,7 +1177,7 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.Get
}
resp.GroupAbstractInfos = utils.Slice(groups, func(group *relationTb.GroupModel) *pbGroup.GroupAbstractInfo {
users := groupUserMap[group.GroupID]
return DbToPbGroupAbstractInfo(group.GroupID, users.MemberNum, users.Hash)
return convert.Db2PbGroupAbstractInfo(group.GroupID, users.MemberNum, users.Hash)
})
return resp, nil
}
@ -1200,7 +1201,7 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge
if e.Nickname == "" {
e.Nickname = nameMap[e.UserID]
}
return DbToPbGroupMembersCMSResp(e)
return convert.Db2PbGroupMembersCMSResp(e)
})
return resp, nil
}
@ -1233,7 +1234,7 @@ func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbGroup.
if e.Nickname == "" {
e.Nickname = nameMap[e.UserID]
}
return DbToPbGroupMembersCMSResp(e)
return convert.Db2PbGroupMembersCMSResp(e)
})
return resp, nil
}

@ -6,6 +6,7 @@ import (
"strings"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
@ -51,7 +52,7 @@ func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.
return e.GroupID, e.MemberIDs
})
resp.Groups = utils.Slice(groupIDs, func(groupID string) *sdkws.GroupInfo {
return DbToPbGroupInfo(groupMap[groupID], ownerMap[groupID].UserID, uint32(len(superGroupMemberMap)))
return convert.Db2PbGroupInfo(groupMap[groupID], ownerMap[groupID].UserID, uint32(len(superGroupMemberMap)))
})
return resp, nil
}
@ -80,7 +81,7 @@ func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSu
return e.GroupID
})
resp.GroupInfos = utils.Slice(groups, func(e *relation.GroupModel) *sdkws.GroupInfo {
return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, uint32(len(superGroupMemberMap[e.GroupID])))
return convert.Db2PbGroupInfo(e, ownerMap[e.GroupID].UserID, uint32(len(superGroupMemberMap[e.GroupID])))
})
return resp, nil
}

@ -1 +1,120 @@
package convert
import (
"time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
pbGroup "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
func Db2PbGroupInfo(m *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo {
return &sdkws.GroupInfo{
GroupID: m.GroupID,
GroupName: m.GroupName,
Notification: m.Notification,
Introduction: m.Introduction,
FaceURL: m.FaceURL,
OwnerUserID: ownerUserID,
CreateTime: m.CreateTime.UnixMilli(),
MemberCount: memberCount,
Ex: m.Ex,
Status: m.Status,
CreatorUserID: m.CreatorUserID,
GroupType: m.GroupType,
NeedVerification: m.NeedVerification,
LookMemberInfo: m.LookMemberInfo,
ApplyMemberFriend: m.ApplyMemberFriend,
NotificationUpdateTime: m.NotificationUpdateTime.UnixMilli(),
NotificationUserID: m.NotificationUserID,
}
}
func Pb2DbGroupRequest(req *pbGroup.GroupApplicationResponseReq, handleUserID string) *relation.GroupRequestModel {
return &relation.GroupRequestModel{
UserID: req.FromUserID,
GroupID: req.GroupID,
HandleResult: req.HandleResult,
HandledMsg: req.HandledMsg,
HandleUserID: handleUserID,
HandledTime: time.Now(),
}
}
func Db2PbCMSGroup(m *relation.GroupModel, ownerUserID string, ownerUserName string, memberCount uint32) *pbGroup.CMSGroup {
return &pbGroup.CMSGroup{
GroupInfo: Db2PbGroupInfo(m, ownerUserID, memberCount),
GroupOwnerUserID: ownerUserID,
GroupOwnerUserName: ownerUserName,
}
}
func Db2PbGroupMembersCMSResp(m *relation.GroupMemberModel) *sdkws.GroupMemberFullInfo {
return &sdkws.GroupMemberFullInfo{
GroupID: m.GroupID,
UserID: m.UserID,
RoleLevel: m.RoleLevel,
JoinTime: m.JoinTime.UnixMilli(),
Nickname: m.Nickname,
FaceURL: m.FaceURL,
//AppMangerLevel: m.AppMangerLevel,
JoinSource: m.JoinSource,
OperatorUserID: m.OperatorUserID,
Ex: m.Ex,
MuteEndTime: m.MuteEndTime.UnixMilli(),
InviterUserID: m.InviterUserID,
}
}
func Db2PbGroupRequest(m *relation.GroupRequestModel, user *sdkws.PublicUserInfo, group *sdkws.GroupInfo) *sdkws.GroupRequest {
return &sdkws.GroupRequest{
UserInfo: user,
GroupInfo: group,
HandleResult: m.HandleResult,
ReqMsg: m.ReqMsg,
HandleMsg: m.HandledMsg,
ReqTime: m.ReqTime.UnixMilli(),
HandleUserID: m.HandleUserID,
HandleTime: m.HandledTime.UnixMilli(),
Ex: m.Ex,
JoinSource: m.JoinSource,
InviterUserID: m.InviterUserID,
}
}
func Db2PbGroupAbstractInfo(groupID string, groupMemberNumber uint32, groupMemberListHash uint64) *pbGroup.GroupAbstractInfo {
return &pbGroup.GroupAbstractInfo{
GroupID: groupID,
GroupMemberNumber: groupMemberNumber,
GroupMemberListHash: groupMemberListHash,
}
}
func Pb2DBGroupInfo(m *sdkws.GroupInfo) *relation.GroupModel {
return &relation.GroupModel{
GroupID: m.GroupID,
GroupName: m.GroupName,
Notification: m.Notification,
Introduction: m.Introduction,
FaceURL: m.FaceURL,
CreateTime: time.Now(),
Ex: m.Ex,
Status: m.Status,
CreatorUserID: m.CreatorUserID,
GroupType: m.GroupType,
NeedVerification: m.NeedVerification,
LookMemberInfo: m.LookMemberInfo,
ApplyMemberFriend: m.ApplyMemberFriend,
NotificationUpdateTime: time.UnixMilli(m.NotificationUpdateTime),
NotificationUserID: m.NotificationUserID,
}
}
func Pb2DbGroupMember(m *sdkws.UserInfo) *relation.GroupMemberModel {
return &relation.GroupMemberModel{
UserID: m.UserID,
Nickname: m.Nickname,
FaceURL: m.FaceURL,
Ex: m.Ex,
}
}

@ -4,6 +4,9 @@ import (
"bytes"
"encoding/json"
"errors"
"io"
"net/http"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
@ -14,8 +17,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis/v8"
"io"
"net/http"
)
type GinMwOptions func(*gin.RouterGroup)

@ -7,7 +7,7 @@ demo_server_binary_root="../bin/"
#Global configuration file default dir
config_path="../docker-compose_cfg/config.yaml"
config_path="../.docker-compose_cfg/config.yaml"
#servicefile dir path
service_source_root=(

@ -8,4 +8,4 @@ sed -i "/^\([[:space:]]*dbMysqlPassword: *\).*/s//\1$PASSWORD/;/\([[:space:]]*db
sed -i "/\([[:space:]]*endpoint: *\).*/s##\1$MINIO_ENDPOINT#;" ../config/config.yaml
sed -i "/\([[:space:]]*dbPassWord: *\).*/s//\1$PASSWORD/;" ../config/config.yaml
sed -i "/\([[:space:]]*secret: *\).*/s//\1$PASSWORD/;" ../docker-compose_cfg/config.yaml
sed -i "/\([[:space:]]*secret: *\).*/s//\1$PASSWORD/;" ../.docker-compose_cfg/config.yaml

Loading…
Cancel
Save