40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
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";
|
|
|
|
import { startSchedulingMonitor } from "./helpers/SchedulingNotifySendMessage"
|
|
import { startWhoIsOnlineMonitor } from "./helpers/WhoIsOnlineMonitor"
|
|
|
|
import { loadTicketsCache, flushCache, cacheSize } from './helpers/TicketCache'
|
|
import { loadContactsCache } from './helpers/ContactsCache'
|
|
|
|
const server = app.listen(process.env.PORT, () => {
|
|
logger.info(`Server started on port: ${process.env.PORT}`);
|
|
});
|
|
|
|
initIO(server);
|
|
StartAllWhatsAppsSessions();
|
|
gracefulShutdown(server);
|
|
|
|
(async()=>{
|
|
|
|
const cacheLength = await cacheSize()
|
|
|
|
console.log('cacheSize: ', cacheLength)
|
|
|
|
if(cacheLength == 0){
|
|
console.log('Loading from cache...')
|
|
await flushCache()
|
|
await loadContactsCache()
|
|
await loadTicketsCache()
|
|
}
|
|
|
|
})()
|
|
|
|
|
|
startSchedulingMonitor(5000)
|
|
startWhoIsOnlineMonitor(3000)
|
|
|