Support for multi-instances of the same node server
In case you have a node server distributed across multiple machines, cores and/or threads, then each process will launch the cron job and then you get multiple executions of the same task.
Is there a solution to this? How would you make the cronjob be at some shared state with the other nodes so that only one actually executes the scheduled cronjob?
Thanks, Ilai.
Just a thought, but perhaps you could configure the jobs to only run on the master (of the clusters).
Actually I'm using pm2 for running the clusters so the master is actually the pm2.
However I ran into https://github.com/TheDeveloper/warlock which uses a redis server for a locking system, so that only one node will win and execute the task.
Thanks for the link. That helped me a lot :)
We seem to have also run into this issue, with our cron jobs running on multiple Heroku dynos -- any suggestions / ideas to workaround this issue?
The way I'd approach this is similar to how @ilaif did. You need some centralized approach and can either do this with a db or some central api server that manages locks for you.
As it stands this module will not do those things, but I do see value in it. Just not within this module itself. I want to keep it pretty light on purpose.