File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
docusaurus/docs/cms/configurations Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -446,7 +446,7 @@ All 3 lifecycle functions can be put together to configure custom behavior durin
4464463 . Restart Strapi to confirm each lifecycle executes in sequence.
447447
448448``` ts title="src/index.ts"
449- let unsubscribeCreate : (() => void ) | undefined ;
449+ let cronJobKey : string | undefined ;
450450
451451export default {
452452 register({ strapi }) {
@@ -458,13 +458,22 @@ export default {
458458 },
459459
460460 async bootstrap({ strapi }) {
461- unsubscribeCreate = strapi .eventHub .subscribe (' entry.create' , (event ) => {
462- strapi .log .info (` New entry created in ${event .model }: ${event .result ?.id } ` );
461+ cronJobKey = ' log-reminders' ;
462+
463+ strapi .cron .add ({
464+ [cronJobKey ]: {
465+ rule: ' 0 */6 * * *' , // every 6 hours
466+ job : async () => {
467+ strapi .log .info (' Remember to review new content in the admin panel.' );
468+ },
469+ },
463470 });
464471 },
465472
466- async destroy() {
467- unsubscribeCreate ?.();
473+ async destroy({ strapi }) {
474+ if (cronJobKey ) {
475+ strapi .cron .remove (cronJobKey );
476+ }
468477 },
469478};
470479```
You can’t perform that action at this time.
0 commit comments