Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using kue-scheduler with ParseServer on Heroku

In running kue-scheduler on heroku with the heroku redis plugin, while I can get kue jobs to work, it seems that kue-scheduler is requiring certain configuration of redis not allowed for in the heroku redis environment. Has anyone had success running kue-scheduler in an Heroku environment. Here is the start of my index.js file:

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

var kue = require('kue-scheduler')
var queue = kue.createQueue({redis:
        'redis://h:***************@ec2-**-19-83-130.compute-1.amazonaws.com:23539'
        });

var job = queue.create('test', {
    title: 'Hello world'
  , to: '[email protected]'
  , template: 'welcome-email'
}).save( function(err){
   if( !err ) console.log( job.id );
});

job.log('$Job %s run', job.id);

queue.every('30 seconds', job);

queue.process('test', function(job, done){
  test_function(job.data.title, done);
});

function test_function(title, done) {
  console.log('Ran test function with title %s', title)
  // email send stuff...
  done();
}

And here is the error.

2016-07-21T00:46:26.445297+00:00 app[web.1]: /app/node_modules/parse-server/lib/ParseServer.js:410
2016-07-21T00:46:26.445299+00:00 app[web.1]:             throw err;
2016-07-21T00:46:26.445300+00:00 app[web.1]:             ^
2016-07-21T00:46:26.445417+00:00 app[web.1]: ReplyError: ERR unknown command 'config'
2016-07-21T00:46:26.445419+00:00 app[web.1]:     at parseError (/app/node_modules/redis-parser/lib/parser.js:161:12)
2016-07-21T00:46:26.445420+00:00 app[web.1]:     at parseType (/app/node_modules/redis-parser/lib/parser.js:222:14)
2016-07-21T00:46:26.466188+00:00 app[web.1]:

The issue is that heroku redis doesn't allow config options on its redis infrastructure from what I can tell.

If someone has had success, grateful for any suggestions.

like image 832
silverdagger Avatar asked Jul 21 '16 00:07

silverdagger


2 Answers

managed to solve this by:

var queue = kue.createQueue(
                {redis: 'redis://[email protected]:23539',
                 skipConfig: true
                });

Just need the skipConfig parameter

like image 62
silverdagger Avatar answered Nov 01 '22 19:11

silverdagger


I was having the same problem and was unable to get kue-scheduler working on Heroku-Redis. To solve, I instead used the Heroku Add-on Redis Cloud.

This allows you to set the required Redis flag notify-keyspace-events which isn't modifiable on the regular Heroku-Redis add-on. To set this flag:

  1. Add Redis Cloud heroku add-on
  2. Go to heroku settings page
  3. Reveal Config Vars in Config Variables
  4. Copy REDISCLOUD_URL, it should be something like redis://rediscloud:[email protected]:PORT_NUMBER
  5. In terminal enter redis-cli -h xxx.redislabs.com -p PORT_NUMBER -a PASSWORD with variables from REDISCLOUD_URL
  6. Once connected, enter config set notify-keyspace-events Ex
  7. You can verify it is set correctly by entering config get notify-keyspace-events
  8. Make sure to update your javascript code to point to your new REDISCLOUD_URL when calling kue.createQueue()

credit to @josephktcheung for their work though here: https://github.com/lykmapipo/kue-scheduler/issues/46

like image 29
Tys Avatar answered Nov 01 '22 19:11

Tys