Related article: Using Kue and Heroku for scheduled jobs on Parse Server
Created
March 14, 2018 10:29
-
-
Save oleg-koval/c31f6dde63396e646530ec39c548cc7b to your computer and use it in GitHub Desktop.
Create the job for expiring round after 24h with kue
This file contains 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 due = require('kue') | |
var redisUrl = process.env.REDIS_URL | |
var jobs = kue.createQueue({ redis: redisUrl }) | |
/** | |
* Create the job for expiring round after 24h | |
*/ | |
function createRoundExpiredJob(round) { | |
jobs.create('roundExpired', { | |
objectId: round.id | |
}) | |
.removeOnComplete(true) | |
.delay(round.createdAt.addADay()) | |
.save() | |
} |
This file contains 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 kue = require('kue') | |
var redisUrl = process.env.REDIS_URL | |
kue.createQueue({ redis: redisUrl }) | |
app.use('/kue', kue.app) // For the kue dashboard |
This file contains 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
web: node index.js | |
worker: node queue.js |
This file contains 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 kue = require('kue') | |
var redisUrl = process.env.REDIS_URL | |
var jobs = kue.createQueue({ redis: redisUrl }) | |
var Parse = require('parse/node') | |
Parse.initialize('masterKey') | |
Parse.serverURL = yourServerUrl | |
/** | |
* Process the job for ending a round after 24h | |
*/ | |
jobs.process('roundExpired', function (job, done) { | |
// Your parse related code and when finished (in save callback for instance): | |
done() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment