HOTFIX: Alinhado a exportação do JOB

This commit is contained in:
Rafael Alves Lopes 2026-02-02 16:26:50 -03:00
parent 55ef702141
commit 0b1d5f5a30
2 changed files with 9 additions and 11 deletions

View File

@ -5,7 +5,7 @@ loadEnv()
const cron = require('node-cron')
const {logError, logInfo} = require('../../shared/utils/logger')
const runWatchdog = require('../../modules/watchdog/job/job')
const {runWatchdog} = require('../../modules/watchdog/job/job.js')
logInfo('[CRON] 🐶 Watchdog cron iniciado')
@ -14,8 +14,9 @@ cron.schedule('*/5 * * * *', async () => {
try {
await runWatchdog()
} catch (error) {
logError('[CRON] ❌ Erro no Watchdog', { error })
} catch (error) {
logError(`[CRON] ❌ Erro no Watchdog: ${error?.message || error}`)
if (error?.stack) logError(error.stack)
}
})

View File

@ -1,18 +1,15 @@
// src/modules/watchdog/job/job.js
const { logError, logInfo } = require('../../../shared/utils/logger')
const { logInfo } = require('../../../shared/utils/logger')
const { notifyCollaborators } = require('../services/notifyCollaborators.service.js')
const { notifyAdmins } = require('../services/notifyAdmins.service.js')
async function runWatchdog() {
const { sentCount: sentFunc } = await notifyCollaborators({ thresholdMinutes: 31 })
const { sentCount: sentAdm } = await notifyAdmins({ sinceMinutes: 30 })
const { sentCount: sentFunc } = await notifyCollaborators({ thresholdMinutes: 31 })
const { sentCount: sentAdm } = await notifyAdmins({ sinceMinutes: 30 })
logInfo(`[WATCHDOG] [JOB] Enviadas ${sentFunc} notificacoes para colaboradores e ${sentAdm} para ADM.`)
logInfo(`[WATCHDOG] [JOB] Enviadas ${sentFunc} notificacoes para colaboradores e ${sentAdm} para ADM.`)
}
runWatchdog().catch((error) => {
logError('[WATCHDOG] [JOB] Erro ao executar o job do Watchdog', error)
})
module.exports = { runWatchdog }