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 "./helpers/SchedulingNotifySendMessage" import { startWhoIsOnlineMonitor } from "./helpers/WhoIsOnlineMonitor" import { loadTicketsCache, flushCache, cacheSize } from './helpers/TicketCache' import { loadContactsCache } from './helpers/ContactsCache' import { loadWhatsappCache } from './helpers/WhatsCache' import { delRestoreControllFile } from "./helpers/RestoreControll"; import { createSessionDir } from "./helpers/CreateSessionDir"; import { loadSchedulesCache, } from "./helpers/SchedulingNotifyCache"; 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() await loadWhatsappCache() await loadSchedulesCache() } })() createSessionDir() delRestoreControllFile() startWhoIsOnlineMonitor(3000)