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-12-18 16:56:45 +00:00
|
|
|
import "./helpers/SchedulingNotifySendMessage"
|
|
|
|
import "./helpers/WhoIsOnlineMonitor"
|
2022-10-25 14:16:36 +00:00
|
|
|
import { loadTicketsCache, flushCache, cacheSize } from './helpers/TicketCache'
|
|
|
|
import { loadContactsCache } from './helpers/ContactsCache'
|
2022-11-17 14:40:37 +00:00
|
|
|
import { loadWhatsappCache } from './helpers/WhatsCache'
|
2022-12-14 12:29:42 +00:00
|
|
|
import { delRestoreControllFile } from "./helpers/RestoreControll";
|
|
|
|
import { createSessionDir } from "./helpers/CreateSessionDir";
|
2022-12-18 16:56:45 +00:00
|
|
|
import { loadSchedulesCache, } from "./helpers/SchedulingNotifyCache";
|
2022-10-25 14:16:36 +00:00
|
|
|
|
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-12-18 16:56:45 +00:00
|
|
|
(async () => {
|
2022-10-25 14:16:36 +00:00
|
|
|
|
|
|
|
const cacheLength = await cacheSize()
|
|
|
|
|
2022-11-08 23:16:39 +00:00
|
|
|
console.log('cacheSize: ', cacheLength)
|
|
|
|
|
2022-12-18 16:56:45 +00:00
|
|
|
if (cacheLength == 0) {
|
2022-10-25 14:16:36 +00:00
|
|
|
console.log('Loading from cache...')
|
2022-12-18 16:56:45 +00:00
|
|
|
await flushCache()
|
2022-10-25 14:16:36 +00:00
|
|
|
await loadContactsCache()
|
|
|
|
await loadTicketsCache()
|
|
|
|
}
|
2022-12-18 16:56:45 +00:00
|
|
|
|
|
|
|
await loadWhatsappCache()
|
|
|
|
await loadSchedulesCache()
|
|
|
|
|
2022-10-25 14:16:36 +00:00
|
|
|
})()
|
2022-12-18 16:56:45 +00:00
|
|
|
|
2022-12-14 12:29:42 +00:00
|
|
|
createSessionDir()
|
|
|
|
delRestoreControllFile()
|
2022-10-25 14:16:36 +00:00
|
|
|
|
|
|
|
|