mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-21 05:09:18 +00:00
chore: add socket-redis config for multinode use
This commit is contained in:
@@ -12,3 +12,6 @@ DB_NAME=
|
|||||||
|
|
||||||
JWT_SECRET=3123123213123
|
JWT_SECRET=3123123213123
|
||||||
JWT_REFRESH_SECRET=75756756756
|
JWT_REFRESH_SECRET=75756756756
|
||||||
|
|
||||||
|
IO_REDIS_SERVER=
|
||||||
|
IO_REDIS_PORT=
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-async-errors": "^3.1.1",
|
"express-async-errors": "^3.1.1",
|
||||||
|
"http-graceful-shutdown": "^2.3.2",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"multer": "^1.4.2",
|
"multer": "^1.4.2",
|
||||||
"mysql2": "^2.2.5",
|
"mysql2": "^2.2.5",
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
"sequelize-cli": "^5.5.1",
|
"sequelize-cli": "^5.5.1",
|
||||||
"sequelize-typescript": "^1.1.0",
|
"sequelize-typescript": "^1.1.0",
|
||||||
"socket.io": "^2.3.0",
|
"socket.io": "^2.3.0",
|
||||||
|
"socket.io-redis": "^5.4.0",
|
||||||
"whatsapp-web.js": "1.11.0",
|
"whatsapp-web.js": "1.11.0",
|
||||||
"yup": "^0.29.3"
|
"yup": "^0.29.3"
|
||||||
},
|
},
|
||||||
@@ -49,6 +51,7 @@
|
|||||||
"@types/multer": "^1.4.4",
|
"@types/multer": "^1.4.4",
|
||||||
"@types/node": "^14.11.8",
|
"@types/node": "^14.11.8",
|
||||||
"@types/socket.io": "^2.1.11",
|
"@types/socket.io": "^2.1.11",
|
||||||
|
"@types/socket.io-redis": "^1.0.26",
|
||||||
"@types/supertest": "^2.0.10",
|
"@types/supertest": "^2.0.10",
|
||||||
"@types/validator": "^13.1.0",
|
"@types/validator": "^13.1.0",
|
||||||
"@types/yup": "^0.29.8",
|
"@types/yup": "^0.29.8",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import socketIo, { Server as SocketIO } from "socket.io";
|
import socketIo, { Server as SocketIO } from "socket.io";
|
||||||
|
import socketRedis from "socket.io-redis";
|
||||||
import { Server } from "http";
|
import { Server } from "http";
|
||||||
import AppError from "../errors/AppError";
|
import AppError from "../errors/AppError";
|
||||||
|
|
||||||
@@ -6,6 +7,14 @@ let io: SocketIO;
|
|||||||
|
|
||||||
export const initIO = (httpServer: Server): SocketIO => {
|
export const initIO = (httpServer: Server): SocketIO => {
|
||||||
io = socketIo(httpServer);
|
io = socketIo(httpServer);
|
||||||
|
if (process.env.IO_REDIS_SERVER) {
|
||||||
|
io.adapter(
|
||||||
|
socketRedis({
|
||||||
|
host: process.env.IO_REDIS_SERVER,
|
||||||
|
port: Number(process.env.IO_REDIS_PORT)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
io.on("connection", socket => {
|
io.on("connection", socket => {
|
||||||
console.log("Client Connected");
|
console.log("Client Connected");
|
||||||
socket.on("joinChatBox", ticketId => {
|
socket.on("joinChatBox", ticketId => {
|
||||||
|
|||||||
@@ -49,5 +49,6 @@
|
|||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
"devDependencies": {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user