Runs the server's recurring tasks. Each module that needs one exports a
Job, and main.ts passes them all to startJobs when it runs
directly, so nothing recurs in the tests, which call a job's run when
they need it.
f
startJobs(jobs: readonly Job[]): void
Starts running each of jobs on its own timer. A run still going when the
next is due makes that one skip, and a run that throws or rejects is logged
and the next one runs anyway.
I
Job
A recurring task, exported by its module for main.ts to start.
-
everyMs: number
How long from one run's start to the next.
-
firstAfterMs: number
How long after the start the first run waits,
everyMsby default. -
name: string
Names it in the log, as
[digest]. -
run(): void | Promise<void>
Logs what it did itself, if anything; its errors are logged here.
Usage
import * as mod from "api/lib/scheduler.ts";