Skip to content

Instantly share code, notes, and snippets.

@frankrousseau
Created August 20, 2012 09:43
Show Gist options
  • Save frankrousseau/3402705 to your computer and use it in GitHub Desktop.
Save frankrousseau/3402705 to your computer and use it in GitHub Desktop.
Kue demo snippet
kue = require 'kue'
jobs = kue.createQueue()
Job = kue.Job
kue.app.listen 3003
job = jobs.create("test complete",
title: "my test"
info: "job is working"
).save()
job.on 'progress', (progress) ->
console.log job.data.title + ' #' + job.id + ' ' + progress + '% complete'
job.on 'complete', () ->
console.log job.data.title + " #" + job.id + " complete"
jobs.process "test complete", 1, (myjob, done) ->
console.log myjob.data.title + " #" + myjob.id + " job started"
setTimeout ->
console.log myjob.data.info
myjob.progress 50, 100
setTimeout ->
done()
, 2000
, 2000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment