
The Strapi Redcron plugin is a drop-in replacement for the Strapi cron plugin that uses Redlock to prevent multiple instances of Strapi from running the same cron job at the same time. This helps to avoid race conditions and potential issues with the database or other integrated services when horizontally scaling Strapi.
To use the Strapi Redcron plugin, you can add the bypassRedcron property to your cron job configuration. This will bypass the redlock logic and allow multiple instances of Strapi to run the same cron job simultaneously.
Note: You need to use the object format of the cron config and provide a unique name for the key property, as Redis needs to lock onto a key that is the same across all instances of Strapi.
Here is an example of how to use the Strapi Redcron plugin:
{
"name": "myCronJob",
"schedule": "*/30 * * * *",
"bypassRedcron": true,
...
}
Feel free to open a pull request if you want to contribute to this project. You can also spin up a new Redis cluster for testing by running docker-compose up in the root of the project. To run multiple Strapi instances, add server.js to the root of your wrapper project and run pm2 start --name="mystrapiapp" server.js -i 2.
The Strapi Redcron plugin is licensed under the MIT License. See the LICENSE file for more information.
Did you find this helpful? If so, please consider giving the plugin a star on NPM Package and GitHub.
Please note that the original links have been removed from the content.

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.