A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
feat: log elapsed cron job time (#742)
Manuel1cf119c76827
diff --git a/packages/cron-jobs-core/src/creator.ts b/packages/cron-jobs-core/src/creator.tsindex 882a2be68..d6e367b5b 100644--- a/packages/cron-jobs-core/src/creator.ts+++ b/packages/cron-jobs-core/src/creator.ts@@ -1,5 +1,6 @@import cron from "node-cron";+import { Stopwatch } from "@homarr/common";import type { MaybePromise } from "@homarr/common/types";import type { Logger } from "./logger";@@ -27,9 +28,14 @@ const createCallback = <TAllowedNames extends string, TName extends TAllowedNameconst catchingCallbackAsync = async () => {try {creatorOptions.logger.logDebug(`The callback of '${name}' cron job started`);+ const stopwatch = new Stopwatch();await creatorOptions.beforeCallback?.(name);+ const beforeCallbackTook = stopwatch.getElapsedInHumanWords();await callback();- creatorOptions.logger.logInfo(`The callback of '${name}' cron job succeeded`);+ const callbackTook = stopwatch.getElapsedInHumanWords();+ creatorOptions.logger.logInfo(+ `The callback of '${name}' cron job succeeded (before callback took ${beforeCallbackTook}, callback took ${callbackTook})`,+ );await creatorOptions.onCallbackSuccess?.(name);} catch (error) {creatorOptions.logger.logError(error);