mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 12:49:32 +00:00
chore: add graceful shutdown
This commit is contained in:
@@ -7,7 +7,8 @@ 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) {
|
|
||||||
|
if (process.env.NODE_ENV === "PRODUCTION") {
|
||||||
io.adapter(
|
io.adapter(
|
||||||
socketRedis({
|
socketRedis({
|
||||||
host: process.env.IO_REDIS_SERVER,
|
host: process.env.IO_REDIS_SERVER,
|
||||||
@@ -15,6 +16,7 @@ export const initIO = (httpServer: Server): SocketIO => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
io.on("connection", socket => {
|
io.on("connection", socket => {
|
||||||
console.log("Client Connected");
|
console.log("Client Connected");
|
||||||
socket.on("joinChatBox", ticketId => {
|
socket.on("joinChatBox", ticketId => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import gracefulShutdown from "http-graceful-shutdown";
|
||||||
import app from "./app";
|
import app from "./app";
|
||||||
import { initIO } from "./libs/socket";
|
import { initIO } from "./libs/socket";
|
||||||
import { StartAllWhatsAppsSessions } from "./services/WbotServices/StartAllWhatsAppsSessions";
|
import { StartAllWhatsAppsSessions } from "./services/WbotServices/StartAllWhatsAppsSessions";
|
||||||
@@ -8,3 +9,4 @@ const server = app.listen(process.env.PORT, () => {
|
|||||||
|
|
||||||
initIO(server);
|
initIO(server);
|
||||||
StartAllWhatsAppsSessions();
|
StartAllWhatsAppsSessions();
|
||||||
|
gracefulShutdown(server);
|
||||||
|
|||||||
Reference in New Issue
Block a user