New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
duplicate cron jobs for apps in cluster mode #393
Comments
I think It is necessary to distinguish between instances. Have you tried this content? |
the link doesn't lead to anywhere |
See Hexagon/croner#86 for a similar problem with solution |
If creating a separated service is an option, you could create a simple cron service in single instance and integrate it with a message-broker like RabbitMQ. |
While running using PM2, you should only invoke the cron tasks on a single instance; else it will run on each instance and you will see the same cron running multiple times. The easiest way to resolve this is to conditionally bind the crons like below (am running a 3 node cluster using PM2) using the env variable
|
Yes, that's the approach I'm currently using. It works fine but my question was more like if there's an official way to do it probided by the library without doing workarounds. For example, the rate limiter library for node has the ability to work with PM2 in cluster mode. |
I'm running a node app with PM2 with cluster mode. I have set up my PM2 config to run 2 instances of the app and as a result, my scheduled cron jobs run twice (once per instance). Is there any way to avoid this?
The text was updated successfully, but these errors were encountered: