Refactor
This commit is contained in:
parent
9d55bd8f78
commit
47d589b0d5
|
@ -9,7 +9,7 @@ import 'regenerator-runtime/runtime'
|
|||
import { logSuccess } from './lib/logger'
|
||||
import { server } from './server'
|
||||
|
||||
import { runTasks } from './tasks'
|
||||
import { startTasks } from './tasks'
|
||||
import './cronTasks'
|
||||
|
||||
server.listen().then(async options => {
|
||||
|
@ -26,5 +26,5 @@ server.listen().then(async options => {
|
|||
}
|
||||
})
|
||||
|
||||
runTasks()
|
||||
startTasks()
|
||||
})
|
||||
|
|
|
@ -5,13 +5,14 @@ import { updateDevicesInfo } from './lib/wifiDevices'
|
|||
|
||||
const SLEEP_IN_MILLISECONDS = process.env.TASK_SLEEP || 10000
|
||||
|
||||
async function updateDevicesTask() {
|
||||
async function runTasks() {
|
||||
logInfo({
|
||||
tags: ['task', 'wifiDevices', 'user-id'],
|
||||
message: 'Atualização de dispositivos iniciou.'
|
||||
})
|
||||
|
||||
try {
|
||||
await updateAccessPoints()
|
||||
await updateDevicesInfo()
|
||||
updateUserIdMappings()
|
||||
} catch (e) {
|
||||
|
@ -21,7 +22,7 @@ async function updateDevicesTask() {
|
|||
data: e
|
||||
})
|
||||
} finally {
|
||||
setTimeout(updateDevicesTask, SLEEP_IN_MILLISECONDS)
|
||||
setTimeout(runTasks, SLEEP_IN_MILLISECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,14 +45,14 @@ async function updateAccessPointsTask() {
|
|||
}
|
||||
}
|
||||
|
||||
function runTasks() {
|
||||
function startTasks() {
|
||||
logInfo({
|
||||
tags: ['task'],
|
||||
message: `Rodando tarefas com ${SLEEP_IN_MILLISECONDS}ms de intervalo.`
|
||||
})
|
||||
|
||||
updateDevicesTask()
|
||||
updateAccessPointsTask()
|
||||
runTasks()
|
||||
|
||||
}
|
||||
|
||||
export { runTasks }
|
||||
export { startTasks }
|
||||
|
|
Loading…
Reference in New Issue
Block a user