Having trouble with a recurring task

19 views
Skip to first unread message

Timothy Nott

unread,
Feb 17, 2014, 9:46:11 PM2/17/14
to action...@googlegroups.com
I'm trying to create a task that will broadcast to chat listeners if there is a change in status on the system.  First, I thought I'd jsut try to get a task to run every 5 seconds and write to the log, but I can't even get that to work.  

Here's my task:

exports.task = {
  name:          'broadcast',
  description:   'broadcast',
  frequency:     5000,
  queue:         'default',
  plugins:       [],
  pluginOptions: {},
  
  run: function(api, params, next){
 var error = null;
 api.log('trying to blow kisses from a task');
    next;
  }

Here's my config for tasks:
config.tasks = {
// Should this node run a scheduler to promote delayed tasks?
scheduler: false,
// what queues should the workers work and how many to spawn?
// ['*'] is one worker working the * queue
// ['high,low'] is one worker working 2 queues
queues: ['default'],
// how long to sleep between jobs / scheduler checks
timeout: 250,
// What redis server should we connect to for tasks / delayed jobs?
redis: config.redis
}


Any ideas?

Thanks!

Evan Tahler

unread,
Feb 18, 2014, 12:28:04 AM2/18/14
to action...@googlegroups.com
2 issues here:

1: `next` is a function that should be called at the completion of the task (it's the callback).  The last line within task.run should be `next();`
2: If you are using delayed or period tasks, you will need to enable a scheduler process.  In the config, change `scheduler: false` to `scheduler: true`
Reply all
Reply to author
Forward
Message has been deleted
0 new messages