Using kue-scheduler with ParseServer on Heroku
Asked Answered
Y

2

6

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.

Yellowbird answered 21/7, 2016 at 0:50 Comment(3)
This issue specifically I was able to resolve via: var Queue = kue.createQueue({ redis: 'redis://x:[email protected]:23539', skipConfig: true } ); However, the recurring tasks don't seem to run.Yellowbird
Did you had to create worker dyno as well to get this whole setup working?Yahiya
I think I've noticed the inconsistencies with the setup that you've in place with skipConfig:true. Can you please verify the behaviour as expected?Yahiya
Y
5

managed to solve this by:

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

Just need the skipConfig parameter

Yellowbird answered 22/7, 2016 at 11:40 Comment(1)
did you end up getting the recurring tasks to work? I have a similar setup, no errors, but no tasks are being run.Wobbly
W
3

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

Wobbly answered 1/2, 2017 at 15:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.