Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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"); });
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()
})
})
}