Cron-cluster
Cron cluster is designed to prevent a job which must be launched only once to be launched many times while an app is scaling accross a cluster with the same task scripts.
Cron cluster is based on node-cron and redis-leader to prevent a cron job to be launched if his process has not been elected as leader on redis.
Requirement
Redis
Install
npm install cron-cluster
Usage
Cron cluster use the same API as the original CronJob.
var redis = var CronJob = redisCronJob { var job = '* * * * * *' { // Do some stuff here } jobstart}
It is possible to initialize CronJob with an object passed as parameter and run the job only once for all the instances. Cron-cluster is compatible with original cron. More in test/cron-cluster-compatibility-check.js
var redis = var CronJob = redisCronJob { var job = cronTime: '* * * * * *' { // Do some stuff here } jobstart}
All you need is to provide a redis client to the cron-cluster module.
Example
Usage with Kue:
var kue = queue = kuevar redis = var CronJob = redisCronJob '* * * * * *' { queue} null true queue