- Ubuntu 16.04 + DOCKER 最新环境
- 配置 Nginx 反向代理
mkdir -p /etc/nginx/conf.d cat << EOF server { listen 80; server_name micro-web-test.srgow.com; location / { proxy_pass http://{主机IP}:8082; } } > /etc/nginx/conf.d/micro-web-test.conf cat << EOF server { listen 80; server_name gateway-test.srgow.com; location / { proxy_pass http://{主机IP}:8089; } } > /etc/nginx/conf.d/gateway-test.conf
- 运行 nginx docker 容器
docker run -d -p 80:80 --name nginx --restart unless-stopped -v /etc/nginx/conf/conf.d:/etc/nginx/conf.d nginx:1.14
- 解压部署包
tar -zxvf chatroom.tar chatroom/path cd chatroom/path cp tool/gcctl /usr/local/bin/
- 配置访问主机hosts文件 (windows)
{聊天室主机IP} gateway-test.srgow.com {聊天室主机IP} micro-web-test.srgow.com
cd chatroom/path
gcctl package
gcctl deploy
- http://micro-web-test.srgow.com/call 可直接调用api
- http://micro-web-test.srgow.com/registry 可查看API调用报文格式
- com.test365.warehouse.alydnh.api 为 外部访问api gateway 3.1 可使用 rest 方式访问 api gateway 如: post http://micro-web-test.srgow.com/api/member/login
- com.test365.warehouse.alydnh.room 为 内部聊天室房间相关接口
- 进入网址: http://micro-web-test.srgow.com/call
- Service: com.test365.warehouse.alydnh.api
- Endpoint: Member.Login
- Request
{"name":"alydnh"}
- 返回:
{ "result": { "success": true }, "token": "登录token" }
- api 调用地址: http://micro-web-test.srgow.com/api/member/login
- 进入网址: http://micro-web-test.srgow.com/call
- Service: com.test365.warehouse.alydnh.room
- Endpoint: RoomService.Create
- Request:
{ "result": { "success": true }, "room": { "id": "fcf602901ef1a0fba0f8533181d0cfb8", "memberNames": [ "alydnh", "realgang", "tracy" ] } }
- 返回:
{ "result": { "success": true }, "room": { "id": "fcf602901ef1a0fba0f8533181d0cfb8", "memberNames": [ "alydnh", "realgang", "tracy" ] } }
- 进入网址: http://micro-web-test.srgow.com/call
- Service: com.test365.warehouse.alydnh.api
- Endpoint: Chat.SendMessage
- Request:
{ "token": "dedf58dc7c31a810ec978a40188da753", "request": { "messages": [ { "roomID": "fcf602901ef1a0fba0f8533181d0cfb8", "labels": { "a": "b" }, "body": { // 数据扩展,限制字符串转换 } } ] } }
- 返回:
{ "result": { "success": true } }
- 进入网址: http://micro-web-test.srgow.com/call
- Service: com.test365.warehouse.alydnh.api
- Endpoint: Chat.ReceiveMessage
- Request:
{ "token":"7c25c3590335ed8fc66229fb8ddc8ebd", "consumeMessageIDs":["1487a81eb698aa11f8b41dab398e082c"], //消费已收到消息,否则会再次收到前次消息 "capacity": 10 // 容量 }
- 返回:
{ "result": { "success": true }, "messages": [ { "sender": "alydnh", "roomID": "fcf602901ef1a0fba0f8533181d0cfb8", "labels": { "a": "b" }, "id": "ec95a0b82a80a67a0c585574530b9af5", "timestamp": "20200803141947" }, { "sender": "alydnh", "roomID": "fcf602901ef1a0fba0f8533181d0cfb8", "labels": { "a": "b" }, "id": "9419a6384f26ad10dd808798300e762f", "timestamp": "20200803141947" }, { "sender": "alydnh", "roomID": "fcf602901ef1a0fba0f8533181d0cfb8", "labels": { "a": "b" }, "id": "2f41f49f3776e47c1e9044c254dfb349", "timestamp": "20200803141948" }, { "sender": "alydnh", "roomID": "fcf602901ef1a0fba0f8533181d0cfb8", "labels": { "a": "b" }, "id": "dfaba19ee9d61f13c52bd5d67d4921dd", "timestamp": "20200803141949" }, { "sender": "alydnh", "roomID": "fcf602901ef1a0fba0f8533181d0cfb8", "labels": { "a": "b" }, "id": "5619c41ea1b54ea9cc8ee0600740af7f", "timestamp": "20200803141949" } ] }