
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
cron-cluster
Advanced tools
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.
Redis
npm install cron-cluster
Cron cluster use the same API as the original CronJob.
var redis = require('redis').createClient()
var CronJob = require('cron-cluster')(redis).CronJob
function doCron () {
var job = new CronJob('* * * * * *', function () {
// Do some stuff here
})
job.start()
}
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 = require('redis').createClient()
var CronJob = require('cron-cluster')(redis).CronJob
function doCron () {
var job = new CronJob({
cronTime: '* * * * * *',
onTick: function () {
// Do some stuff here
}
})
job.start()
}
All you need is to provide a redis client to the cron-cluster module.
Usage with Kue:
var kue = require('kue'),
queue = kue.createQueue()
var redis = require('redis').createClient()
var CronJob = require('cron-cluster')(redis).CronJob
new CronJob('* * * * * *', function () {
queue.create('log', {
text: 'this is a log'
}).save()
}, null, true)
queue.process('log', function (job, done) {
console.log(job.data.text)
done()
})
FAQs
A Cluster version of node-cron using redis
The npm package cron-cluster receives a total of 2,693 weekly downloads. As such, cron-cluster popularity was classified as popular.
We found that cron-cluster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.