Skip to content

Instantly share code, notes, and snippets.

@yornaath
Created December 1, 2011 13:44
Show Gist options
  • Save yornaath/1416817 to your computer and use it in GitHub Desktop.
Save yornaath/1416817 to your computer and use it in GitHub Desktop.
Proposed node_jobs spec snippet
var jobs = require('jobs')
jobs.persistenceAdapter('mongodb', 'mongodb://localhost/jobs')
.resumeOnRestart()
.spawnPersistent({
name: 'keyvaluestore_cleaner',
url: '../examplejobs/keyvaluestore_cleaner.js'
})
.run().every('30minute 2second')
function userLoggsIn(req, res){
req.user.twitterjob = jobs.spawn({
name: 'twitteragregator'
url: '../examplejobs/twitteragregator.js'
}, [user])
.run().every('2minute')
}
function userLoggsOut(req, res) {
req.user.twitterjob.kill()
}
//uncovered
job.sleep()
job.wake()
job.run().in('2hour')
job.run().now()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment