Skip to content

Instantly share code, notes, and snippets.

@sese
Created May 7, 2018 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sese/651af2fc29cf76c23a1777a1cb982dfa to your computer and use it in GitHub Desktop.
Save sese/651af2fc29cf76c23a1777a1cb982dfa to your computer and use it in GitHub Desktop.
var Queue = require('bull')

var queueName = 'cron-daily'
var q = new Queue(queueName, 'redis://localhost:6379')

var name = "World"
var cnt = 1
var cronExpr = {cron: "*/1 * * * *"}

q.process(function(job) {
	console.log("Hello %s %s. JobId: %s", cnt++, name, job.id)
	return Promise.resolve("done.")
})

q.add(null, {repeat: cronExpr})

setTimeout(function() {
	q.removeRepeatable(queueName, cronExpr).then(function() {
		console.log("cron removed")
		name = "Manuel"
	})

}, 60*1000*3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment