How to use the node-resque.worker function in node-resque

To help you get started, we’ve selected a few node-resque examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github evantahler / background_jobs_node / 5-combined.js View on Github external
res.end(JSON.stringify(response, null, 2));
  });
};

var queue = new NR.queue({connection: connectionDetails}, jobs);
queue.connect(function(){
  http.createServer(server).listen(httpPort, httpHost);
  console.log('Server running at ' + httpHost + ':' + httpPort);
  console.log('send an email and message to /TO_ADDRESS/SUBJECT/YOUR_MESSAGE');
});

///////////////////
// RESQUE WORKER //
///////////////////

var worker = new NR.worker({connection: connectionDetails, queues: ['emailQueue']}, jobs);
worker.connect(function(){
  worker.workerCleanup();
  worker.start();
});

worker.on('start',           function(){ console.log("worker started"); });
worker.on('end',             function(){ console.log("worker ended"); });
worker.on('cleaning_worker', function(worker, pid){ console.log("cleaning old worker " + worker); });
worker.on('poll',            function(queue){ console.log("worker polling " + queue); });
worker.on('job',             function(queue, job){ console.log("working job " + queue + " " + JSON.stringify(job)); });
worker.on('reEnqueue',       function(queue, job, plugin){ console.log("reEnqueue job (" + plugin + ") " + queue + " " + JSON.stringify(job)); });
worker.on('success',         function(queue, job, result){ console.log("job success " + queue + " " + JSON.stringify(job) + " >> " + result); });
worker.on('failure',         function(queue, job, failure){ console.log("job failure " + queue + " " + JSON.stringify(job) + " >> " + failure); });
worker.on('error',           function(queue, job, error){ console.log("error " + queue + " " + JSON.stringify(job) + " >> " + error); });
worker.on('pause',           function(){ console.log("worker paused"); });
github OpenNeuroOrg / openneuro / server / libs / queue / worker.js View on Github external
redis_connect(config.redis).then(redis => {
    const workerConfig = {
      connection: { redis: redis },
      looping: true,
      timeout: 5000,
      queues: ['*'],
      name: os.hostname() + ':' + process.pid,
    }

    worker = new NR.worker(workerConfig, tasks)

    worker.connect(() => {
      worker.workerCleanup()
      worker.start()
    })
  })
}

node-resque

an opinionated implementation of resque in node

Apache-2.0
Latest version published 5 months ago

Package Health Score

80 / 100
Full package analysis