0

I'm trying to use kue for scheduled jobs on my Parse Server (hosted on heroku). For now I've modified my index.js file like so as stated in the several tutorials I found about Kue :

var express = require('express')
  , kue = require('due')
  , redis = require('redis');

var ParseServer = require('parse-server').ParseServer;

var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI;

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  masterKey: process.env.MASTER_KEY || '',
  serverURL: process.env.SERVER_URL
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

// connect to REDIS
var client = redis.createClient(process.env.REDIS_URL);

var app = express();

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api)
.use(kue.app); // wire up Kue (see /active for queue interface)


// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
  res.status(200).send('I dream of being a web site.');
});

var port = process.env.PORT || 1337;
app.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

I've found out that the app crashes at the line : .use(kue.app). Here is the error I get :

Starting process with command `node index.js`
parse-server-example running on port 22995.
/app/node_modules/parse-server/lib/index.js:298
        throw err;
        ^

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
    at Object.exports._errnoException (util.js:890:11)
    at exports._exceptionWithHostPort (util.js:913:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1057:14)
Process exited with status 7
State changed from starting to crashed

I don't know why this is happening.

Ambroise Collon
  • 3,839
  • 3
  • 18
  • 37
  • Hello! You recently had commented on an issue on the Parse Server Platform about how you use kue for scheduled push notifications. I have been trying to implement them with no success. Would you mind checking out my [question](http://stackoverflow.com/questions/37103639/how-to-schedule-a-job-with-kue-on-parse-server)? Thank you!!! – Baylor Mitchell May 09 '16 at 21:03

1 Answers1

0

The line : .use(ku.app) can be removed. And all that is needed is to add :

var jobs = kue.createQueue({ redis: process.env.REDIS_URL })

to access the current queue.

Hope it'll helps somebody.

Ambroise Collon
  • 3,839
  • 3
  • 18
  • 37