chore: change all internal cron tasks to named tasks

This commit is contained in:
Derrick Mehaffy 2024-09-20 21:06:51 -07:00
parent 504076d216
commit 6e4ffcae2c
5 changed files with 27 additions and 5 deletions

View File

@ -49,7 +49,10 @@ const sendUpdateProjectInformation = async (strapi: Core.Strapi) => {
const startCron = (strapi: Core.Strapi) => { const startCron = (strapi: Core.Strapi) => {
strapi.cron.add({ strapi.cron.add({
'0 0 0 * * *': () => sendUpdateProjectInformation(strapi), sendProjectInformation: {
task: () => sendUpdateProjectInformation(strapi),
options: '0 0 0 * * *',
},
}); });
}; };

View File

@ -30,7 +30,10 @@ const sendUpdateProjectInformation = async (strapi: Core.Strapi) => {
const startCron = (strapi: Core.Strapi) => { const startCron = (strapi: Core.Strapi) => {
strapi.cron.add({ strapi.cron.add({
'0 0 0 * * *': () => sendUpdateProjectInformation(strapi), sendProjectInformation: {
task: () => sendUpdateProjectInformation(strapi),
options: '0 0 0 * * *',
},
}); });
}; };

View File

@ -205,7 +205,13 @@ const checkLicense = async ({ strapi }: { strapi: Core.Strapi }) => {
if (!shouldStayOffline) { if (!shouldStayOffline) {
await onlineUpdate({ strapi }); await onlineUpdate({ strapi });
strapi.cron.add({ [shiftCronExpression('0 0 */12 * * *')]: onlineUpdate });
strapi.cron.add({
onlineUpdate: {
task: () => onlineUpdate({ strapi }),
options: shiftCronExpression('0 0 */12 * * *'),
},
});
} else { } else {
if (!ee.licenseInfo.expireAt) { if (!ee.licenseInfo.expireAt) {
return disable('Your license does not have offline support.'); return disable('Your license does not have offline support.');

View File

@ -70,7 +70,12 @@ export default ({ strapi }: { strapi: Core.Strapi }) => {
async registerCron() { async registerCron() {
const weeklySchedule = await this.ensureWeeklyStoredCronSchedule(); const weeklySchedule = await this.ensureWeeklyStoredCronSchedule();
strapi.cron.add({ [weeklySchedule]: this.sendMetrics.bind(this) }); strapi.cron.add({
reviewWorkflowsWeekly: {
task: this.sendMetrics.bind(this),
options: weeklySchedule,
},
});
}, },
}; };
}; };

View File

@ -129,6 +129,11 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
async registerCron() { async registerCron() {
const weeklySchedule = await this.ensureWeeklyStoredCronSchedule(); const weeklySchedule = await this.ensureWeeklyStoredCronSchedule();
strapi.cron.add({ [weeklySchedule]: this.sendMetrics.bind(this) }); strapi.cron.add({
uploadWeekly: {
task: this.sendMetrics.bind(this),
options: weeklySchedule,
},
});
}, },
}); });