Last active
March 12, 2018 20:15
-
-
Save flovilmart/4ce71e8c3b65f31ac2b4 to your computer and use it in GitHub Desktop.
Simple Queue for Parse hosted on Heroku with Kue, Redis
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
web: node web.js | |
worker: node worker.js |
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 rtg = require("url").parse(process.env.REDISCLOUD_URL); | |
var kue = require('kue'); | |
var redisOptions = { | |
host: rtg.hostname, | |
port: 14353, | |
auth: rtg.auth.split(":")[1] | |
} | |
var queue = kue.createQueue({ | |
redis: redisOptions | |
}); | |
var express = require("express"); | |
var app = express(); | |
app.use(kue.app); | |
app.listen(process.env.PORT || 3000); | |
/* | |
TO CREATE A JOB: | |
https://github.com/LearnBoost/kue#post-job | |
*/ |
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 rtg = require("url").parse(REDISCLOUD_URL); | |
var kue = require('kue'); | |
var Parse = require("parse").Parse; | |
Parse.initialize(process.env.PARSE_APP_ID, process.env.PARSE_JS_KEY, process.env.PARSE_MASTER_KEY); | |
var redisOptions = { | |
host: rtg.hostname, | |
port: 14353, | |
auth: rtg.auth.split(":")[1] | |
} | |
var queue = kue.createQueue({ | |
redis: redisOptions | |
}); | |
queue.promote(1); | |
/* | |
https://github.com/LearnBoost/kue#processing-jobs | |
*/ | |
queue.process('doSomethingVeryLong', function(job, done){ | |
// Process you job here | |
// All my users are awesome now :) | |
var usersQuery = new Parse.Query(Parse.User); | |
usersQuery.each(function(user){ | |
user.set("isAwesome", true); | |
return user.save() | |
}).then(function(){ | |
job.complete() | |
done(); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@flovilmart is this still current?