Skip to content

Instantly share code, notes, and snippets.

@oleg-koval
Created March 14, 2018 10:29
Show Gist options
  • Save oleg-koval/c31f6dde63396e646530ec39c548cc7b to your computer and use it in GitHub Desktop.
Save oleg-koval/c31f6dde63396e646530ec39c548cc7b to your computer and use it in GitHub Desktop.
Create the job for expiring round after 24h with kue
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()
}
var kue = require('kue')
var redisUrl = process.env.REDIS_URL
kue.createQueue({ redis: redisUrl })
app.use('/kue', kue.app) // For the kue dashboard
web: node index.js
worker: node queue.js
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