feat: add job on start option for icons updater (#442)

This commit is contained in:
Meier Lukas
2024-05-05 22:20:38 +02:00
committed by GitHub
parent 4b80b16b53
commit 7b31684c84
2 changed files with 79 additions and 70 deletions

View File

@@ -2,9 +2,20 @@ import cron from "node-cron";
import type { MaybePromise } from "@homarr/common/types";
export const createCronJob = (cronExpression: string) => {
interface CreateCronJobOptions {
runOnStart?: boolean;
}
export const createCronJob = (
cronExpression: string,
options: CreateCronJobOptions = { runOnStart: false },
) => {
return {
withCallback: (callback: () => MaybePromise<void>) => {
if (options.runOnStart) {
void callback();
}
const task = cron.schedule(cronExpression, () => void callback(), {
scheduled: false,
});