HOTFIX: Alinhado a exportação do JOB
This commit is contained in:
parent
55ef702141
commit
0b1d5f5a30
@ -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)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -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 }
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user