2022-01-06 01:26:15 +00:00
|
|
|
import gracefulShutdown from "http-graceful-shutdown";
|
|
|
|
import app from "./app";
|
|
|
|
import { initIO } from "./libs/socket";
|
|
|
|
import { logger } from "./utils/logger";
|
|
|
|
import { StartAllWhatsAppsSessions } from "./services/WbotServices/StartAllWhatsAppsSessions";
|
|
|
|
|
2022-03-01 03:27:17 +00:00
|
|
|
import { startSchedulingMonitor } from "./helpers/SchedulingNotifySendMessage"
|
2022-05-16 02:48:06 +00:00
|
|
|
import { startWhoIsOnlineMonitor } from "./helpers/WhoIsOnlineMonitor"
|
2022-03-01 03:27:17 +00:00
|
|
|
|
2022-10-25 14:16:36 +00:00
|
|
|
import { loadTicketsCache, flushCache, cacheSize } from './helpers/TicketCache'
|
|
|
|
import { loadContactsCache } from './helpers/ContactsCache'
|
|
|
|
|
2022-01-06 01:26:15 +00:00
|
|
|
const server = app.listen(process.env.PORT, () => {
|
|
|
|
logger.info(`Server started on port: ${process.env.PORT}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
initIO(server);
|
|
|
|
StartAllWhatsAppsSessions();
|
|
|
|
gracefulShutdown(server);
|
2022-03-01 03:27:17 +00:00
|
|
|
|
2022-10-25 14:16:36 +00:00
|
|
|
(async()=>{
|
|
|
|
|
|
|
|
const cacheLength = await cacheSize()
|
|
|
|
|
|
|
|
if(cacheLength == 0){
|
|
|
|
console.log('Loading from cache...')
|
|
|
|
await flushCache()
|
|
|
|
await loadContactsCache()
|
|
|
|
await loadTicketsCache()
|
|
|
|
}
|
|
|
|
|
|
|
|
})()
|
|
|
|
|
|
|
|
|
2022-03-01 03:27:17 +00:00
|
|
|
startSchedulingMonitor(5000)
|
2022-10-25 14:16:36 +00:00
|
|
|
startWhoIsOnlineMonitor(3000)
|
|
|
|
|