Habilitação do envio de informação de espaço no servidor
parent
c4258b3431
commit
b309a43fe3
|
@ -102,47 +102,47 @@ const monitor = async () => {
|
|||
|
||||
|
||||
// WHATS SESSION SIZE MONITORING
|
||||
const whatsapps = await ListWhatsAppsService();
|
||||
// const whatsapps = await ListWhatsAppsService();
|
||||
|
||||
whatsapps.forEach(async whats => {
|
||||
// whatsapps.forEach(async whats => {
|
||||
|
||||
|
||||
|
||||
const sourcePath = path.join(__dirname, `../../.wwebjs_auth/`, `session-bd_${whats.id}`)
|
||||
// const sourcePath = path.join(__dirname, `../../.wwebjs_auth/`, `session-bd_${whats.id}`)
|
||||
|
||||
if (fs.existsSync(sourcePath)) {
|
||||
// if (fs.existsSync(sourcePath)) {
|
||||
|
||||
try {
|
||||
// try {
|
||||
|
||||
const fastFolderSizeAsync = promisify(fastFolderSize)
|
||||
// const fastFolderSizeAsync = promisify(fastFolderSize)
|
||||
|
||||
let size = await fastFolderSizeAsync(sourcePath)
|
||||
// let size = await fastFolderSizeAsync(sourcePath)
|
||||
|
||||
size = convertBytes(size)
|
||||
// size = convertBytes(size)
|
||||
|
||||
|
||||
// SESSION MONITORING
|
||||
const io = getIO();
|
||||
io.emit("whatsappSessionMonit", {
|
||||
action: "update",
|
||||
whatsappSessionSize: {
|
||||
id: whats.id,
|
||||
sessionSize: size
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
console.log('An error occurred while get info from the directory: ', err);
|
||||
}
|
||||
// // SESSION MONITORING
|
||||
// const io = getIO();
|
||||
// io.emit("whatsappSessionMonit", {
|
||||
// action: "update",
|
||||
// whatsappSessionSize: {
|
||||
// id: whats.id,
|
||||
// sessionSize: size
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// catch (err) {
|
||||
// console.log('An error occurred while get info from the directory: ', err);
|
||||
// }
|
||||
|
||||
}
|
||||
else {
|
||||
// }
|
||||
// else {
|
||||
|
||||
// console.log('Directory not found to get size info: ', sourcePath)
|
||||
// // console.log('Directory not found to get size info: ', sourcePath)
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,13 @@ import { StartAllWhatsAppsSessions } from "./services/WbotServices/StartAllWhats
|
|||
import User from "./models/User";
|
||||
import Whatsapp from "./models/Whatsapp";
|
||||
import endPointQuery from "./helpers/EndPointQuery";
|
||||
import { cacheSize, flushCache, loadTicketsCache } from "./helpers/TicketCache";
|
||||
import { loadContactsCache } from "./helpers/ContactsCache";
|
||||
import { loadSchedulesCache } from "./helpers/SchedulingNotifyCache";
|
||||
import { delRestoreControllFile } from "./helpers/RestoreControll";
|
||||
|
||||
import "./helpers/SchedulingNotifySendMessage"
|
||||
|
||||
|
||||
const server = app.listen(process.env.PORT, () => {
|
||||
logger.info(`Server started on port: ${process.env.PORT}`);
|
||||
|
@ -44,7 +51,7 @@ gracefulShutdown(server);
|
|||
}
|
||||
|
||||
} catch (error: any) {
|
||||
|
||||
|
||||
await whatsapps[i].update({ status: 'OPENING' });
|
||||
|
||||
console.log(`There was an error on try acess the api sessions ${whatsapps[i].dataValues.url}`)
|
||||
|
@ -55,6 +62,25 @@ gracefulShutdown(server);
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (process.env.CACHE) {
|
||||
|
||||
const cacheLength = await cacheSize()
|
||||
|
||||
console.log('cacheSize: ', cacheLength)
|
||||
|
||||
if (cacheLength == 0) {
|
||||
console.log('Loading from cache...')
|
||||
await flushCache()
|
||||
await loadContactsCache()
|
||||
await loadTicketsCache()
|
||||
}
|
||||
|
||||
await loadSchedulesCache()
|
||||
// await loadWhatsappCache()
|
||||
}
|
||||
|
||||
delRestoreControllFile()
|
||||
})()
|
||||
|
||||
setTimeout(async () => {
|
||||
|
|
Loading…
Reference in New Issue