Merge remote-tracking branch 'origin/main'

This commit is contained in:
Gordon 2021-05-27 11:41:04 +08:00
commit 0397a2d179
6 changed files with 115 additions and 118 deletions

215
README.md
View File

@ -1,6 +1,5 @@
# Open-IM-Server # Open-IM-Server
Open-IM-Server is open source instant messaging Server.Backend in Go. ![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/open-im-logo.png)
![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Open-IM.png)
[![LICENSE](https://img.shields.io/badge/license-Apache--2.0-green)](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/LICENSE) [![LICENSE](https://img.shields.io/badge/license-Apache--2.0-green)](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/LICENSE)
[![Language](https://img.shields.io/badge/Language-Go-blue.svg)](https://golang.org/) [![Language](https://img.shields.io/badge/Language-Go-blue.svg)](https://golang.org/)
@ -45,103 +44,103 @@ business data.
#### Building from Source #### Building from Source
> Open-IM relies on five open source high-performance components: **ETCD**, **MySQL**, **MongoDB**, **Redis**, **Kafka**. Before you deploy Open-IM-Server privately, please make sure that you have installed the above five components and **check the component connection parameters** in the configuration file. you must install the missing components first,If your server does not have the above components. **It is recommended to use it directly, if you have the above components, if not, Docker installation is recommended, which is faster and more convenient**.
1. Install [Go environment](https://golang.org/doc/install). Make sure Go version is at least 1.15. 1. Install [Go environment](https://golang.org/doc/install). Make sure Go version is at least 1.15.
2. Open-IM relies on five open source high-performance components: **Etcd**, **MySQL**, **MongoDB**, **Redis**, **Kafka**. Before you deploy Open-IM privately, please make sure that you have installed the above five components and **check the component parameters ** in the configuration file. If your server does not have the above components, you must install the missing components first. **If you have the above components, it is recommended to use them directly, if not, Docker installation is recommended, which is faster and more convenient**. 3. Git clone Open-IM project
3. Git clone Open-IM project
``` ```
git clone https://github.com/tinode/chat https://github.com/OpenIMSDK/Open-IM-Server.git
``` ```
4. Open [config.yaml](https://github.com/Open-IM-IM/opim_admin/blob/main/config/config.yaml),then modify the following parameters. 4. Open [config.yaml](https://github.com/Open-IM-IM/opim_admin/blob/main/config/config.yaml),then modify the following parameters.
- Check that the Etcd connection parameters. - Check that the ETCD connection parameters.
``` ```
etcd: etcd:
etcdAddr: [ xxx.xxx.xxx.xxx:2379] etcdAddr: [ 127.0.0.1:2379]
``` ```
- Check or modify database(MySQL) connection parameters are correct for your database. - Check or modify database(MySQL) connection parameters are correct for your database.
``` ```
mysql: mysql:
dbAddress: [ xxx.xxx.xxx.xxx:3306] dbAddress: [ 127.0.0.1:3306]
dbUserName: xxx dbUserName: xxx
dbPassword: xxx dbPassword: xxx
``` ```
- Check or modify database(MongoDB) connection parameters are correct for your database. - Check or modify database(MongoDB) connection parameters are correct for your database.
``` ```
mongo: mongo:
dbAddress: [xxx.xxx.xxx.xxx:27017 ] dbAddress: [ 127.0.0.1:27017 ]
dbUserName: dbUserName:
dbPassword: dbPassword:
``` ```
- Check or modify Redis connection parameters. - Check or modify Redis connection parameters.
``` ```
redis: redis:
dbAddress: [xxx.xxx.xxx.xxx:6379] dbAddress: [ 127.0.0.1:6379]
dbPassWord: dbPassWord:
``` ```
- Check or modify Kafka connection parameters. - Check or modify Kafka connection parameters.
``` ```
kafka: kafka:
ws2mschat: ws2mschat:
addr: [ xxx.xxx.xxx.xxx:9092 ] addr: [ 127.0.0.1:9092 ]
ms2pschat: ms2pschat:
addr: [ xxx.xxx.xxx.xxx:9092 ] addr: [ 127.0.0.1:9092 ]
``` ```
5. Build Open-IM server and database initializer: 5. Build Open-IM server and database initializer:
- **MySQL** - **MySQL**
``` ```
... need to add
``` ```
- **MongoDB** - **MongoDB**
``` ```
... need to add
``` ```
6. Enter the script directory and execute the script according to the steps。 6. Enter the script directory and execute the script according to the steps。
1. Shell authorization 1. Shell authorization
``` ```
chmod +x *.sh chmod +x *.sh
``` ```
2. Execute build shell 2. Execute build shell
``` ```
./auto_build_service_file.sh ./build_all_service.sh
``` ```
3. Start service 3. Start service
``` ```
./auto_start_service.sh ./start_all.sh
``` ```
#### Using Docker to run Open-IM-Server #### Using Docker to run Open-IM-Server
> Open-IM relies on five open source high-performance components: **ETCD**, **MySQL**, **MongoDB**, **Redis**, **Kafka**. Before you deploy Open-IM-Server privately, please make sure that you have installed the above five components and **check the component connection parameters** in the configuration file. you must install the missing components first,If your server does not have the above components. **It is recommended to use it directly, if you have the above components, if not, Docker installation is recommended, which is faster and more convenient**.
All images are available at https://hub.docker.com/r/lyt1123/open_im_server All images are available at https://hub.docker.com/r/lyt1123/open_im_server
1. [Install Docker](https://docs.docker.com/install/) 1.13 or above. 1. [Install Docker](https://docs.docker.com/install/) 1.13 or above.
2. Open-IM relies on five open source high-performance components: **Etcd**, **MySQL**, **MongoDB**, **Redis**, **Kafka**. Before you deploy Open-IM privately, please make sure that you have installed the above five components and **check the component parameters ** in the configuration file. If your server does not have the above components, you must install the missing components first. **If you have the above components, it is recommended to use them directly, if not, Docker installation is recommended, which is faster and more convenient**.
3. Pull Open_IM_Server Image from docker 3. Pull Open_IM_Server Image from docker
``` ```
@ -152,56 +151,56 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
4. External config file,the container comes with a built-in config file which can be customized with values from the environment variables .**If changes are extensive it may be more convenient to replace the built-in config file with a custom one**. In that case map the config file located on your host. 4. External config file,the container comes with a built-in config file which can be customized with values from the environment variables .**If changes are extensive it may be more convenient to replace the built-in config file with a custom one**. In that case map the config file located on your host.
- Create configuration folder directory - Create configuration folder directory
``` ```
mkdir -p open_im_server/config mkdir -p open_im_server/config
``` ```
- Download the [config.yaml](https://github.com/Open-IM-IM/opim_admin/blob/main/config/config.yaml) file from github, then modify the following parameters - Download the [config.yaml](https://github.com/Open-IM-IM/opim_admin/blob/main/config/config.yaml) file from github, then modify the following parameters
- Check or modify the Etcd connection parameters. - Check or modify the Etcd connection parameters.
``` ```
etcd: etcd:
etcdAddr: [ x.x.x.x:2379] etcdAddr: [ 127.0.0.1:2379]
``` ```
- Check or modify database(MySQL) connection parameters are correct for your database. - Check or modify database(MySQL) connection parameters are correct for your database.
``` ```
mysql: mysql:
dbAddress: [ x.x.x.x:3306] dbAddress: [ 127.0.0.1:3306]
dbUserName: xxx dbUserName: xxx
dbPassword: xxx dbPassword: xxx
``` ```
- Check or modify database(MongoDB) connection parameters are correct for your database. - Check or modify database(MongoDB) connection parameters are correct for your database.
``` ```
mongo: mongo:
dbAddress: [ x.x.x.x:27017 ] dbAddress: [ 127.0.0.1:27017 ]
dbUserName: dbUserName:
dbPassword: dbPassword:
``` ```
- Check or modify the Redis connection parameters. - Check or modify the Redis connection parameters.
``` ```
redis: redis:
dbAddress: [x.x.x.x:6379] dbAddress: [ 127.0.0.1:6379]
dbPassWord: dbPassWord:
``` ```
- Check or modify the Kafka connection parameters. - Check or modify the Kafka connection parameters.
``` ```
kafka: kafka:
ws2mschat: ws2mschat:
addr: [ x.x.x.x:9092 ] addr: [ 127.0.0.1:9092 ]
ms2pschat: ms2pschat:
addr: [ x.x.x.x:9092 ] addr: [ 127.0.0.1:9092 ]
``` ```
5. Start Open-IM-Server Service 5. Start Open-IM-Server Service
@ -209,13 +208,13 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
docker run -p 10000:10000 -p 7777:7777 --name open_im_server -v /home/open_im_server/logs:/home/open_im_server/logs -v /home/open_im_server/config/config.yaml:/home/open_im_server/config/config.yaml --restart always -d docker.io/lyt1123/open_im_server:[tag] docker run -p 10000:10000 -p 7777:7777 --name open_im_server -v /home/open_im_server/logs:/home/open_im_server/logs -v /home/open_im_server/config/config.yaml:/home/open_im_server/config/config.yaml --restart always -d docker.io/lyt1123/open_im_server:[tag]
``` ```
- -p 10000:10000 The container port maps the host 10000 port, provides api service. - -p 10000:10000 The container port maps the host 10000 port, provides api service.
- -p 7777:7777 The container port maps the host 7777 port, provides message services. - -p 7777:7777 The container port maps the host 7777 port, provides message services.
- --name open_im_server Container service name - --name open_im_server Container service name
- -v /home/open_im_server/logs:/home/open_im_server/logs The container log directory maps the host directory - -v /home/open_im_server/logs:/home/open_im_server/logs The container log directory maps the host directory
- -v /home/open_im_server/config/config.yaml:/home/open_im_server/config/config.yaml The container configuration file maps the host configuration file - -v /home/open_im_server/config/config.yaml:/home/open_im_server/config/config.yaml The container configuration file maps the host configuration file
- --restart always Automatically start when the container is closed abnormally - --restart always Automatically start when the container is closed abnormally
- -d Running service in the background - -d Running service in the background
### CONFIGURATION INSTRUCTIONS ### CONFIGURATION INSTRUCTIONS
>Open-IM configuration is divided into basic component configuration and business internal service configuration. Developers need to fill in the address of each component as the address of their server component when using the product, and ensure that the internal service port of the business is not occupied >Open-IM configuration is divided into basic component configuration and business internal service configuration. Developers need to fill in the address of each component as the address of their server component when using the product, and ensure that the internal service port of the business is not occupied
@ -328,8 +327,8 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
``` ```
appapp client appapp client
app-serverapp server app-serverapp server
open-im-sdkTuoyun's open source sdk open-im-sdkopen-im source sdk
open-im-serverTuoyun's open source sdk service open-im-serveropen-im source sdk service
``` ```
- **Authentication Clow Chart** - **Authentication Clow Chart**

View File

@ -5,10 +5,10 @@
#---------------Infrastructure configuration---------------------# #---------------Infrastructure configuration---------------------#
etcd: etcd:
etcdSchema: openIM etcdSchema: openIM
etcdAddr: [ 47.112.160.66:2379 ] etcdAddr: [ 127.0.0.1:2379 ]
mysql: mysql:
dbAddress: [ 47.112.160.66:3306 ] dbAddress: [ 127.0.0.1:3306 ]
dbUserName: root dbUserName: root
dbPassword: 123456 dbPassword: 123456
dbDatabaseName: openIM dbDatabaseName: openIM
@ -19,7 +19,7 @@ mysql:
dbMaxLifeTime: 120 dbMaxLifeTime: 120
mongo: mongo:
dbAddress: [ 47.112.160.66:27017 ] dbAddress: [ 127.0.0.1:27017 ]
dbDirect: false dbDirect: false
dbTimeout: 10 dbTimeout: 10
dbDatabase: [ openIM ] dbDatabase: [ openIM ]
@ -30,7 +30,7 @@ mongo:
dbRetainChatRecords: 7 dbRetainChatRecords: 7
redis: redis:
dbAddress: [47.112.160.66:6379] dbAddress: [ 127.0.0.1:6379 ]
dbMaxIdle: 128 dbMaxIdle: 128
dbMaxActive: 0 dbMaxActive: 0
dbIdleTimeout: 120 dbIdleTimeout: 120
@ -38,10 +38,10 @@ redis:
kafka: kafka:
ws2mschat: ws2mschat:
addr: [ 47.112.160.66:9092 ] addr: [ 127.0.0.1:9092 ]
topic: "ws2ms_chat" topic: "ws2ms_chat"
ms2pschat: ms2pschat:
addr: [ 47.112.160.66:9092 ] addr: [ 127.0.0.1:9092 ]
topic: "ms2ps_chat" topic: "ms2ps_chat"
consumergroupid: consumergroupid:
msgToMongo: mongo msgToMongo: mongo

BIN
docs/open-im-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

1
go.mod
View File

@ -12,7 +12,6 @@ require (
github.com/eapache/go-resiliency v1.2.0 // indirect github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect github.com/eapache/queue v1.1.0 // indirect
github.com/favadi/protoc-go-inject-tag v1.1.0 // indirect
github.com/frankban/quicktest v1.11.3 // indirect github.com/frankban/quicktest v1.11.3 // indirect
github.com/garyburd/redigo v1.6.2 github.com/garyburd/redigo v1.6.2
github.com/gin-gonic/gin v1.6.3 github.com/gin-gonic/gin v1.6.3

2
go.sum
View File

@ -46,8 +46,6 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/favadi/protoc-go-inject-tag v1.1.0 h1:rSTVJya9GF6mcqOO2KRAppvVMHqIkSzG9ORflxqflNA=
github.com/favadi/protoc-go-inject-tag v1.1.0/go.mod h1:13goAxKedbu5IbfI0n2wIKh1CCgZOwPNZQd0igDWvko=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY= github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY=

View File

@ -4,6 +4,7 @@ import (
"Open_IM/src/common/config" "Open_IM/src/common/config"
"Open_IM/src/common/db" "Open_IM/src/common/db"
"errors" "errors"
"github.com/dgrijalva/jwt-go"
"time" "time"
) )