14 lines
465 B
TypeScript
14 lines
465 B
TypeScript
import { FastifyInstance } from "fastify"
|
|
|
|
const SYNC_INTERVAL_MS = 5 * 60 * 1000
|
|
|
|
export function startDocumentImportWorker(server: FastifyInstance) {
|
|
const run = () => server.services.documentImports.syncAll().catch((error) => {
|
|
server.log.error({ error }, "Automatischer Dokumentenimport fehlgeschlagen")
|
|
})
|
|
|
|
const timer = setInterval(run, SYNC_INTERVAL_MS)
|
|
timer.unref()
|
|
server.addHook("onClose", async () => clearInterval(timer))
|
|
}
|