Created
December 1, 2011 13:44
-
-
Save yornaath/1416817 to your computer and use it in GitHub Desktop.
Proposed node_jobs spec snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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