diff --git a/lib/queue/job.js b/lib/queue/job.js index 9a0573cd..a588d7e0 100644 --- a/lib/queue/job.js +++ b/lib/queue/job.js @@ -288,6 +288,7 @@ Job.prototype.log = function(str){ }); this.client.rpush('q:job:' + this.id + ':log', str); + this.set('updated_at', Date.now()); return this; }; @@ -334,6 +335,7 @@ Job.prototype.progress = function(complete, total){ if (0 == arguments.length) return this._progress; var n = Math.min(100, complete / total * 100 | 0); this.set('progress', n); + this.set('updated_at', Date.now()); events.emit(this.id, 'progress', n); return this; }; @@ -388,6 +390,7 @@ Job.prototype.attempt = function(fn){ client.hsetnx(key, 'max_attempts', 1, function(){ client.hget(key, 'max_attempts', function(err, max){ client.hincrby(key, 'attempts', 1, function(err, attempts){ + self.set('updated_at', Date.now()); fn(err, Math.max(0, max - attempts), attempts, max); }); }); @@ -460,6 +463,7 @@ Job.prototype.state = function(state){ client.zadd('q:jobs:' + this.type + ':' + state, this._priority, this.id); // increase available jobs, used by Worker#getJob() if ('inactive' == state) client.lpush('q:' + this.type + ':jobs', 1); + this.set('updated_at', Date.now()); return this; };