Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pushing a number of resque logs deeper #612

Merged
merged 3 commits into from
Mar 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ exports.default = {
scheduler: false,
// what queues should the taskProcessors work?
queues: ['*'],
// Verbosity of task logging
verbose: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that I like having a log option outside of the logging config file.

Perhaps the answer is a hash with each event => log level?

{start: "debug", poll: "trace"}

// how long to sleep between jobs / scheduler checks
timeout: 5000,
// at minimum, how many parallel taskProcessors should this node spawn?
Expand All @@ -31,4 +33,4 @@ exports.test = {
checkTimeout: 50
}
}
}
}
8 changes: 5 additions & 3 deletions initializers/resque.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
initialize: function(api, next){

api.resque = {
verbose: false,
queue: null,
multiWorker: null,
scheduler: null,
Expand Down Expand Up @@ -54,6 +55,7 @@ module.exports = {

startMultiWorker: function(callback){
var self = this;
this.verbose = api.config.tasks.verbose;

self.multiWorker = new NR.multiWorker({
connection: api.resque.connectionDetails,
Expand All @@ -66,9 +68,9 @@ module.exports = {
toDisconnectProcessors: api.config.tasks.toDisconnectProcessors,
}, api.tasks.jobs, function(){
// normal worker emitters
self.multiWorker.on('start', function(workerId){ api.log('worker: started', 'info', {workerId: workerId} ); })
self.multiWorker.on('end', function(workerId){ api.log('worker: ended', 'info', {workerId: workerId} ); })
self.multiWorker.on('cleaning_worker', function(workerId, worker, pid){ api.log('worker: cleaning old worker ' + worker + '(' + pid + ')', 'info' ); })
self.multiWorker.on('start', function(workerId){ api.log('worker: started', (self.verbose) ? 'info':'trace', {workerId: workerId} ); })
self.multiWorker.on('end', function(workerId){ api.log('worker: ended', (self.verbose) ? 'info':'trace', {workerId: workerId} ); })
self.multiWorker.on('cleaning_worker', function(workerId, worker, pid){ api.log('worker: cleaning old worker ' + worker + '(' + pid + ')', (self.verbose) ? 'info':'trace' ); })
self.multiWorker.on('poll', function(workerId, queue){ api.log('worker: polling ' + queue, 'trace', {workerId: workerId} ); })
self.multiWorker.on('job', function(workerId, queue, job){ api.log('worker: working job ' + queue, 'debug', {workerId: workerId, job: {class: job.class, queue: job.queue}} ); })
self.multiWorker.on('reEnqueue', function(workerId, queue, job, plugin){ api.log('worker: reEnqueue job', 'debug', {workerId: workerId, plugin: plugin, job: {class: job.class, queue: job.queue}} ); })
Expand Down