A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
fix: ping urls are not reset when restarting (#924)
Meier Lukas365e267b8d7b
diff --git a/packages/cron-jobs-core/src/creator.ts b/packages/cron-jobs-core/src/creator.tsindex 7418ff158..62607377e 100644--- a/packages/cron-jobs-core/src/creator.ts+++ b/packages/cron-jobs-core/src/creator.ts@@ -16,6 +16,7 @@ export interface CreateCronJobCreatorOptions<TAllowedNames extends string> {interface CreateCronJobOptions {runOnStart?: boolean;+ beforeStart?: () => MaybePromise<void>;}const createCallback = <TAllowedNames extends string, TName extends TAllowedNames>(@@ -62,6 +63,11 @@ const createCallback = <TAllowedNames extends string, TName extends TAllowedNamecronExpression,scheduledTask,async onStartAsync() {+ if (options.beforeStart) {+ creatorOptions.logger.logDebug(`Running beforeStart for job: ${name}`);+ await options.beforeStart();+ }+if (!options.runOnStart) return;creatorOptions.logger.logDebug(`The cron job '${name}' is running because runOnStart is set to true`);diff --git a/packages/cron-jobs/src/jobs/ping.ts b/packages/cron-jobs/src/jobs/ping.tsindex e9b353112..a164fd369 100644--- a/packages/cron-jobs/src/jobs/ping.ts+++ b/packages/cron-jobs/src/jobs/ping.ts@@ -5,7 +5,14 @@ import { pingChannel, pingUrlChannel } from "@homarr/redis";import { createCronJob } from "../lib";-export const pingJob = createCronJob("ping", EVERY_MINUTE).withCallback(async () => {+const resetPreviousUrlsAsync = async () => {+ await pingUrlChannel.clearAsync();+ logger.info("Cleared previous ping urls");+};++export const pingJob = createCronJob("ping", EVERY_MINUTE, {+ beforeStart: resetPreviousUrlsAsync,+}).withCallback(async () => {const urls = await pingUrlChannel.getAllAsync();for (const url of new Set(urls)) {diff --git a/packages/redis/src/lib/channel.ts b/packages/redis/src/lib/channel.tsindex 0fd1b45f4..f707e20c0 100644--- a/packages/redis/src/lib/channel.ts+++ b/packages/redis/src/lib/channel.ts@@ -77,6 +77,12 @@ export const createListChannel = <TItem>(name: string) => {removeAsync: async (item: TItem) => {await getSetClient.lrem(listChannelName, 0, superjson.stringify(item));},+ /**+ * Clear all items from the channels list+ */+ clearAsync: async () => {+ await getSetClient.del(listChannelName);+ },/*** Add an item to the channels list* @param item item to add