From 6e4ffcae2caa2a95f3ac61ea8f64c86dc20da5cb Mon Sep 17 00:00:00 2001 From: Derrick Mehaffy Date: Fri, 20 Sep 2024 21:06:51 -0700 Subject: [PATCH] chore: change all internal cron tasks to named tasks --- packages/core/admin/ee/server/src/services/metrics.ts | 5 ++++- packages/core/admin/server/src/services/metrics.ts | 5 ++++- packages/core/core/src/ee/index.ts | 8 +++++++- .../server/src/services/metrics/weekly-metrics.ts | 7 ++++++- .../core/upload/server/src/services/weekly-metrics.ts | 7 ++++++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/core/admin/ee/server/src/services/metrics.ts b/packages/core/admin/ee/server/src/services/metrics.ts index 18fb9d6a42..0f46432c2e 100644 --- a/packages/core/admin/ee/server/src/services/metrics.ts +++ b/packages/core/admin/ee/server/src/services/metrics.ts @@ -49,7 +49,10 @@ const sendUpdateProjectInformation = async (strapi: Core.Strapi) => { const startCron = (strapi: Core.Strapi) => { strapi.cron.add({ - '0 0 0 * * *': () => sendUpdateProjectInformation(strapi), + sendProjectInformation: { + task: () => sendUpdateProjectInformation(strapi), + options: '0 0 0 * * *', + }, }); }; diff --git a/packages/core/admin/server/src/services/metrics.ts b/packages/core/admin/server/src/services/metrics.ts index 67626e7b97..b5818ed7a6 100644 --- a/packages/core/admin/server/src/services/metrics.ts +++ b/packages/core/admin/server/src/services/metrics.ts @@ -30,7 +30,10 @@ const sendUpdateProjectInformation = async (strapi: Core.Strapi) => { const startCron = (strapi: Core.Strapi) => { strapi.cron.add({ - '0 0 0 * * *': () => sendUpdateProjectInformation(strapi), + sendProjectInformation: { + task: () => sendUpdateProjectInformation(strapi), + options: '0 0 0 * * *', + }, }); }; diff --git a/packages/core/core/src/ee/index.ts b/packages/core/core/src/ee/index.ts index 770107d725..f22302bd53 100644 --- a/packages/core/core/src/ee/index.ts +++ b/packages/core/core/src/ee/index.ts @@ -205,7 +205,13 @@ const checkLicense = async ({ strapi }: { strapi: Core.Strapi }) => { if (!shouldStayOffline) { await onlineUpdate({ strapi }); - strapi.cron.add({ [shiftCronExpression('0 0 */12 * * *')]: onlineUpdate }); + + strapi.cron.add({ + onlineUpdate: { + task: () => onlineUpdate({ strapi }), + options: shiftCronExpression('0 0 */12 * * *'), + }, + }); } else { if (!ee.licenseInfo.expireAt) { return disable('Your license does not have offline support.'); diff --git a/packages/core/review-workflows/server/src/services/metrics/weekly-metrics.ts b/packages/core/review-workflows/server/src/services/metrics/weekly-metrics.ts index 8bd5913d87..b6efeae3c2 100644 --- a/packages/core/review-workflows/server/src/services/metrics/weekly-metrics.ts +++ b/packages/core/review-workflows/server/src/services/metrics/weekly-metrics.ts @@ -70,7 +70,12 @@ export default ({ strapi }: { strapi: Core.Strapi }) => { async registerCron() { const weeklySchedule = await this.ensureWeeklyStoredCronSchedule(); - strapi.cron.add({ [weeklySchedule]: this.sendMetrics.bind(this) }); + strapi.cron.add({ + reviewWorkflowsWeekly: { + task: this.sendMetrics.bind(this), + options: weeklySchedule, + }, + }); }, }; }; diff --git a/packages/core/upload/server/src/services/weekly-metrics.ts b/packages/core/upload/server/src/services/weekly-metrics.ts index b415e8aff2..b70d4cf2d1 100644 --- a/packages/core/upload/server/src/services/weekly-metrics.ts +++ b/packages/core/upload/server/src/services/weekly-metrics.ts @@ -129,6 +129,11 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({ async registerCron() { const weeklySchedule = await this.ensureWeeklyStoredCronSchedule(); - strapi.cron.add({ [weeklySchedule]: this.sendMetrics.bind(this) }); + strapi.cron.add({ + uploadWeekly: { + task: this.sendMetrics.bind(this), + options: weeklySchedule, + }, + }); }, });