Some checks failed
Deploy application / deploy (push) Failing after 7s
- Moved database to subdir specified by env - Default data dir /data - Move loggers to cronJob onTick - Added volume for data dir in Docker compose - Create any missing dir specified by env
21 lines
494 B
TypeScript
21 lines
494 B
TypeScript
import { CronJob } from "cron"
|
|
import logger from "@/logger.ts"
|
|
|
|
/**
|
|
* Run a function every day at 1 AM, Oslo time.
|
|
* @param onTick Function to run.
|
|
* @returns CronJob instance.
|
|
*/
|
|
export function cronJobDaily(onTick: () => Promise<void>): CronJob {
|
|
return CronJob.from({
|
|
cronTime: "0 0 1 * * *",
|
|
onTick: async () => {
|
|
logger.info("Starting daily job")
|
|
await onTick()
|
|
logger.info("Finished daily job")
|
|
},
|
|
start: true,
|
|
timeZone: "Europe/Oslo",
|
|
})
|
|
}
|