Use funtion to run tasks
This commit is contained in:
parent
9abba52d7d
commit
e2542091f8
|
@ -6,8 +6,6 @@ import oui from 'oui'
|
|||
|
||||
import { deleteOldLogs, log, logInfo, logSuccess } from './lib/logger'
|
||||
|
||||
import { updateUserIdMappings } from './lib/paloalto'
|
||||
|
||||
logInfo({
|
||||
tags: ['cron'],
|
||||
message: 'Scheduling tasks...'
|
||||
|
|
|
@ -15,7 +15,7 @@ logInfo({
|
|||
: 'Running in development'
|
||||
})
|
||||
|
||||
import './tasks'
|
||||
import { runTasks } from './tasks'
|
||||
import './cronTasks'
|
||||
|
||||
server.listen().then(options => {
|
||||
|
@ -28,3 +28,5 @@ server.listen().then(options => {
|
|||
}
|
||||
})
|
||||
})
|
||||
|
||||
runTasks()
|
||||
|
|
|
@ -4,11 +4,6 @@ import { updateDevicesInfo } from './lib/wifiDevices'
|
|||
|
||||
const SLEEP_IN_MILLISECONDS = process.env.TASK_SLEEP || 10000
|
||||
|
||||
logInfo({
|
||||
tags: ['task'],
|
||||
message: `Running tasks with ${SLEEP_IN_MILLISECONDS}ms sleeps.`
|
||||
})
|
||||
|
||||
async function updateDevicesTask() {
|
||||
try {
|
||||
logInfo({
|
||||
|
@ -34,4 +29,13 @@ async function updateDevicesTask() {
|
|||
}
|
||||
}
|
||||
|
||||
function runTasks() {
|
||||
logInfo({
|
||||
tags: ['task'],
|
||||
message: `Running tasks with ${SLEEP_IN_MILLISECONDS}ms sleeps.`
|
||||
})
|
||||
|
||||
updateDevicesTask()
|
||||
}
|
||||
|
||||
export { runTasks }
|
||||
|
|
Loading…
Reference in New Issue
Block a user