File size: 563 Bytes
5dfc565
 
 
 
 
652f343
 
5dfc565
652f343
 
 
 
 
 
 
 
 
deae345
 
 
 
 
652f343
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { initFolders } from "./initFolders.mts"
import { getPendingTasks } from "./scheduler/getPendingTasks.mts"
import { processTask } from "./scheduler/processTask.mts"

initFolders()

export const main = async () => {

  const tasks = await getPendingTasks()
  if (!tasks.length) {
    setTimeout(() => {
      main()
    }, 500)
    return
  }

  console.log(`there are ${tasks.length} pending tasks`)
  for (const task of tasks) {
    await processTask(task)
  }
  console.log(`processed ${tasks.length} tasks`)

  setTimeout(() => {
    main()
  }, 1000)
}