Browse --- Chat --- Wekan

Commit a0f410f2 authored by kc's avatar kc
Browse files

Only give consul leader if logged in

parent fa5f9199
Showing with 9 additions and 2 deletions
+9 -2
......@@ -2,7 +2,7 @@ version: "3"
services:
main:
build: .
image: jestrr/monitor:0.12.3
image: jestrr/monitor:0.12.4
entrypoint: ["pm2", "start", "/home/app/src/config/pm2.config.js", "--no-daemon"]
volumes:
- /etc/ssl/creds:/home/app/creds
......
......@@ -109,7 +109,7 @@ module.exports = {
evt.type === "status" && this.getServerStatus(chatroom, evt, ws);
evt.type === "services" && this.checkDataCenters(chatroom, evt, ws);
evt.type === "updateCenters" && this.checkCenters();
evt.type === "getLeader" && ws.send(JSON.stringify({type: "getLeader", msg: CONSUL_LEADER}))
evt.type === "getLeader" && this.sendLeader(chatroom, evt, ws);
})
ws.on("close", (evt) => {
let peerInd = connectedPeers.findIndex((masterPeer) => masterPeer.wsId === wsId)
......@@ -119,6 +119,13 @@ module.exports = {
});
},
sendLeader: function(chatroom, evt, ws) {
this.canSendInfo(ws, (canSend) => {
canSend && ws.send(JSON.stringify({type: "getLeader", msg: CONSUL_LEADER}))
!canSend && ws.send(JSON.stringify({type: "getLeader", msg: ""}))
})
},
getServerStatus: function (chatroom, evt, ws) {
health.getServerStatus((apps) => {
let response = { type: "status", apps: apps }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment